Skip to content

Instantly share code, notes, and snippets.

@nonopolarity
Created September 15, 2012 21:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nonopolarity/3729857 to your computer and use it in GitHub Desktop.
Save nonopolarity/3729857 to your computer and use it in GitHub Desktop.
print out view and its subviews hierarchy
-(void) printSubviews:(NSView *) view withLevel:(int) level {
NSLog(@"%*s%@ frame: %@", level * 4, "", view, NSStringFromRect(view.frame));
for (NSView *sv in [view subviews]) {
[self printSubviews:sv withLevel:level+1];
}
}
-(void) printSubviews:(NSView *) view {
NSLog(@"Hierarchy:");
[self printSubviews:view withLevel:0];
}
- (void) applicationDidFinishLaunching:(NSNotification *) aNotification {
[self printSubviews:self.window.contentView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment