Under the Bridge

recursiveDescription + Controllers

Now this is a pretty sweet addition to your debugging tricks – how to easily see what controllers are part of a view hierarchy:

Pimping recursiveDescription

While working on PSPDFKit, I more and more embrace viewController containment to better distribute responsibilities between different view controllers. One thing that always annoyed me about that is that po [[UIWindow keyWindow] recursiveDescription] is less and less useful if you just see a big bunch of UIView’s. I asked some engineers at WWDC if there’s something like recursiveDescription, just for UIViewControllers, but they didn’t had a answer on that, so I finally wrote my own … As a bonus, this also lists attached childViewControllers if you run iOS5 or above, and it will show you if a childViewController has a greater frame than it’s parentViewController (this is usually a easy to miss bug)…

Cool beans, yep. Unfortunately, for those of you immediately thinking that would be some handy introspection ability for your production code too, note carefully

For those if you that are curious, I use a private API call (_viewDelegate), but that’s obfuscated (it would pass a AppStore review) and you really only should compile that function in DEBUG mode anyway.

so you probably don’t want to risk that. But if you do have a really good reason for needing to do that, check out this Stack Overflow question for ideas!

h/t: ‏@steipete!

0