From 9533093c9d107acaaf26110a2ae43f484a101419 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Mon, 17 Jan 2011 20:24:17 +0000 Subject: Add a -description method to SPTreeNode to aid debugging. --- Source/SPTreeNode.m | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Source/SPTreeNode.m b/Source/SPTreeNode.m index 79217a9f..7be4f09a 100644 --- a/Source/SPTreeNode.m +++ b/Source/SPTreeNode.m @@ -250,21 +250,25 @@ #pragma mark - #pragma mark Other -/*- (NSComparisonResult)compare:(SPTreeNode *)node +- (NSString *)description { - id selfObject = [self representedObject]; - id nodeObject = [node representedObject]; + NSMutableString *description = [NSMutableString string]; - if ([selfObject isKindOfClass:[SPFavoriteNode class]] && [nodeObject isKindOfClass:[SPFavoriteNode class]]) { - - return [[[selfObject nodeFavorite] objectForKey:SPFavoriteNameKey] localizedCaseInsensitiveCompare:[[nodeObject nodeFavorite] objectForKey:SPFavoriteNameKey]]; - } - else if ([selfObject isKindOfClass:[SPGroupNode class]] && [nodeObject isKindOfClass:[SPGroupNode class]]) { + [description appendString:[[self representedObject] description]]; + [description appendString:@"\n"]; + + NSArray *nodes = [self childNodes]; + + for (NSUInteger i = 0; i < [nodes count]; i++) + { + SPTreeNode *node = [nodes objectAtIndex:i]; + + [description appendString:([node isGroup]) ? [node description] : [[node representedObject] description]]; - return [[selfObject nodeName] localizedCaseInsensitiveCompare:[nodeObject nodeName]]; + if (i < ([nodes count] - 1)) [description appendString:@"\n"]; } - return NSOrderedSame; -}*/ + return description; +} @end -- cgit v1.2.3