I am working on a medium-size iOS code base and am not the primary developer. I often find myself in a position where I run the app in the iOS simulator, see a view I know I would like to edit or use (e.g. a textview whose text I would like to get), but then don't have a good way of tracing said view back to a file in the code base. My question is, are there any good ways (either deterministically or heuristically) to "back trace" from a view one sees in the running instantiation of the app in the iOS simulator back to the code file/interface builder file that actually defines/contains said view?
For example, I see a textview in the simulator whose text I'd like to set differently, and I want a way to find the .xib/storyboard the textview is defined in and/or any IBOutlet's to it. I have tried using Reveal App, which seems to give some information about the app's overall view structure and view classes, but I haven't been able to reference this back to a code and/or interface builder file. Reveal App does show the memory address of views - perhaps there is a way to use this in combination with lldb to figure out which file the view came from?
I know its a very old question. However, if you are still looking for an answer, you could break execution at any arbitrary point and use the lldb to print out some information.
Then, if, for example, your app, like most other apps, has a UINavigationController as a root view controller, then you could try and see whats the top view controller. If that's a TabView, then a little more digging.. u get the drift...
po [(UINavigationController *)[[[UIApplication sharedApplication] keyWindow] rootViewController] topViewController]
This seems to work fairly well. Not too straightforward, but not a bad deal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With