如何在 XCode 控制台中按十六进制查找实例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3403806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find instance by hex in XCode console?
提问by marty
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.
当我在 iPhone 应用程序崩溃后打开控制台时,它经常说“无法识别的选择器发送到实例 0x blah blah blah blah ”。我怎样才能找出这是什么变量?调试器中有没有办法?甚至有可能吗?谢谢。
回答by kennytm
In gdb you could type
在 gdb 中你可以输入
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.
-description
在该地址打印对象的 。但这些信息很少有用。您应该先检查异常的回溯,这样可以定位导致问题的代码行。
回答by whyoz
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.
创建异常断点非常有帮助,而且使用 Xcode 7.3,从未如此简单。这将帮助您找到导致异常的代码行。
- add breakpoint on the line where the app crashes
- click the breakpoint in the Project Navigator menu
- find the breakpoint you just created and select it
- click the "+" at the bottom left
- Select "Add Exception Breakpoint"
- 在应用程序崩溃的行上添加断点
- 单击 Project Navigator 菜单中的断点
- 找到你刚刚创建的断点并选择它
- 点击左下角的“+”
- 选择“添加异常断点”
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.
运行你的代码……每当你收到一个“无法识别的选择器发送到实例 0x blah blah blah ”时,调试器将在导致问题的行上停止。