Skip to content

Instantly share code, notes, and snippets.

@erikkerber
Last active December 31, 2015 04:29
Show Gist options
  • Save erikkerber/7934785 to your computer and use it in GitHub Desktop.
Save erikkerber/7934785 to your computer and use it in GitHub Desktop.
Recursive viewcontroller description
#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