How to find instance by hex in XCode console?

假如想象 提交于 2019-11-29 11:31:49

问题


When I bring up console after my iPhone app crashes, it often says "unrecognized selector sent to instance 0x blah blah blah." How can I find out what variable this is? Is there a way in the debugger? Is it even possible? Thanks.


回答1:


In gdb you could type

po 0x12345678

to print the -description of the object at that address. But this info is seldom useful. You should instead check the backtrace of the exception first, which can locate the line of code that causes the problem.




回答2:


It's very helpful to create an Exception breakpoint, and with Xcode 7.3, it's never been easier. This will help you find the line of code causing an exception.

  1. add breakpoint on the line where the app crashes
  2. click the breakpoint in the Project Navigator menu
  3. find the breakpoint you just created and select it
  4. click the "+" at the bottom left
  5. Select "Add Exception Breakpoint"

Run your code...whenever you get a "unrecognized selector sent to instance 0x blah blah blah," the debugger will stop on the line that's causing the problem.



来源:https://stackoverflow.com/questions/3403806/how-to-find-instance-by-hex-in-xcode-console

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!