Does the Debug View Hierarchy in Xcode allow me to see what view controller owns a view?
1 Answer
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.
UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t)
4 Comments
Dali
An example would be
(lldb) po [0x0123456789ab nextResponder], right?wolfrevo
That should work, you may need to cast the pointer to (id) if lldb complains.
mfaani
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?wolfrevo
This is unrelated to view controllers, but
po [(UILabel *)0x7fb1de6e2030 text] should work.