Last active
December 31, 2015 04:29
-
-
Save erikkerber/7934785 to your computer and use it in GitHub Desktop.
Recursive viewcontroller description
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 "UIViewController+RecursiveDescription.h" | |
@implementation UIViewController (RecursiveDescription) | |
-(NSString*)recursiveDescription | |
{ | |
NSMutableString *description = [NSMutableString stringWithFormat:@"\n"]; | |
[self addDescriptionToString:description indentLevel:0]; | |
return description; | |
} | |
-(void)addDescriptionToString:(NSMutableString*)string indentLevel:(NSInteger)indentLevel | |
{ | |
NSString *padding = [@"" stringByPaddingToLength:indentLevel withString:@" " startingAtIndex:0]; | |
[string appendString:padding]; | |
[string appendFormat:@"%@, %@",[self debugDescription],NSStringFromCGRect(self.view.frame)]; | |
for (UIViewController *childController in self.childViewControllers) | |
{ | |
[string appendFormat:@"\n%@",padding]; | |
[childController addDescriptionToString:string indentLevel:indentLevel + 1]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment