Last active
August 29, 2015 13:56
-
-
Save rkachowski/8801621 to your computer and use it in GitHub Desktop.
Do the same as UIKit#recursiveDescription, but for CCNode instead of UIView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import "CCNode.h" | |
@interface CCNode (RecursiveDescription) | |
- (NSString*)recursiveDescription; | |
@end | |
@implementation CCNode (RecursiveDescription) | |
- (NSString*)recursiveDescription | |
{ | |
return [self recursivelyListChildren:0]; | |
} | |
- (NSString*)recursivelyListChildren:(NSUInteger)depth | |
{ | |
NSString * padding = @""; | |
for(int i =0; i < depth;i++) | |
{ | |
padding = [NSString stringWithFormat:@"%@ | ", padding]; | |
} | |
NSString *description = [NSString stringWithFormat:@"%@%@", padding, self.description]; | |
NSMutableArray *children = [@[description] mutableCopy]; | |
for(CCNode * node in _children) | |
{ | |
[children addObject:[node recursivelyListChildren:depth + 1]]; | |
} | |
return [children componentsJoinedByString:@"\n"]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment