Skip to content

Instantly share code, notes, and snippets.

@kespindler
Created August 19, 2011 01:18
Show Gist options
  • Save kespindler/1155771 to your computer and use it in GitHub Desktop.
Save kespindler/1155771 to your computer and use it in GitHub Desktop.
View entire uiview hierarchy.
Easy Way to Debug UIView Hierarchy
Do you want to see complete view hierarchy for debugging purposes? There is an easy way to do it, provided by Apple - totally unofficially!
Actually official documentation says it's undocumented and not supported. No problem with that. Very kind of Apple, good developer service!
Found this in Technical Note TN2239 "iOS Debugging Magic", section "Cocoa and Cocoa Touch - UIKit":
UIView implements a useful description method. In addition, it implements a recursiveDescription method that you can call to get a summary of an entire view hierarchy.
Therefore I could have saved lots of time and effort in How to Find MFMailComposeViewController Email Addresses with a single line of code. Just to verify that it's not possioble to find recipient email addresses by digging deep into view hierarchy I could have used this:
NSLog(@"%@", [controller.view recursiveDescription]);
Well, I did learn a lot. Both times.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment