Skip to content

Instantly share code, notes, and snippets.

@rbsgn
Created March 19, 2011 16:44
Show Gist options
  • Save rbsgn/877593 to your computer and use it in GitHub Desktop.
Save rbsgn/877593 to your computer and use it in GitHub Desktop.
Debugging mode for UIViews: Dumps subviews description to console
#import <UIKit/UIKit.h>
@interface UIView (YXDebug)
- (NSString *)subtreeDescription;
@end
#import "UIView-YXDebug.h"
@implementation UIView (YXDebug)
- (NSString *)subtreeDescriptionWithIndent:(NSString *)indent {
NSMutableString * desc = [NSMutableString string];
[desc appendFormat:@"%@%@\n", indent, [self description]];
NSString * subindent = [indent stringByAppendingString:@" "];
for (UIView * v in [self subviews]) {
[desc appendFormat:@"%@", [v subtreeDescriptionWithIndent:subindent]];
}
return desc;
}
- (NSString *)subtreeDescription {
return [self subtreeDescriptionWithIndent:@""];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment