From ed56f8effb6e50d3926e72d4aebd674fc9c584c7 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 4 Aug 2007 19:58:27 -0700 Subject: [PATCH] Removing some NSLog()s and in isLeaf: we now determine if a non-leaf node has it's children * Source/NSXMLElementAdditions.m: ([NSXMLElement variable]): Remove a NSLog() ([NSXMLElement isLeaf]): If the element is not a leaf, but does not have children, then find the depth we should request more about the property at --- Source/NSXMLElementAdditions.m | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Source/NSXMLElementAdditions.m b/Source/NSXMLElementAdditions.m index 8f1bf4b..381f03c 100644 --- a/Source/NSXMLElementAdditions.m +++ b/Source/NSXMLElementAdditions.m @@ -23,7 +23,6 @@ */ - (NSString *)variable { - NSLog(@"name = %@", [self attributes]); return [[self attributeForName: @"name"] stringValue]; } @@ -32,8 +31,24 @@ */ - (BOOL)isLeaf { - NSLog(@"isleaf"); - return ([[[self attributeForName: @"children"] stringValue] intValue] == 0); + BOOL leaf = ([[[self attributeForName: @"children"] stringValue] intValue] == 0); + + // hmm... we're not a leaf but have no children. this must be beyond our depth, so go make us + // deeper + if (!leaf && [[self children] count] < 1) + { + // count upwards to see how deep we should go + int depth = 0; + NSXMLElement *elm = self; + while (elm != nil) + { + depth++; + elm = [elm parent]; + } + NSLog(@"let's go to depth %d for %@", depth, self); + } + + return leaf; } /** -- 2.22.5