11

Does the Debug View Hierarchy in Xcode allow me to see what view controller owns a view?

1 Answer 1

17

Update: Starting with Xcode 9, view controllers are listed right along the view hierarchy in the visual debugger.

You can get the memory address of the selected view from the inspector in Xcode and then use the console to get the view's view controller using -nextResponder.

http://developer.apple.com/library/ios/documentation/uikit/reference/UIResponder_Class/Reference/Reference.html#//apple_ref/occ/instm/UIResponder/nextResponder

UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t)

Sign up to request clarification or add additional context in comments.

4 Comments

An example would be (lldb) po [0x0123456789ab nextResponder], right?
That should work, you may need to cast the pointer to (id) if lldb complains.
what exactly works in during view debug hierarchy? When I use it, I can see the pointer to UIlabels, but when I try to do something like po 0x7fb1de6e2030.text I get an error. I was hoping somehow I could cast it to UILabel but had no success there. Any solution?
This is unrelated to view controllers, but po [(UILabel *)0x7fb1de6e2030 text] should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.