如何检测哪个线程以及崩溃的位置?

时间:2011-11-18 15:45:53

标签: objective-c cocoa-touch

我在iOS上使用XMPP框架,有时会崩溃。每当我调试它永远不会崩溃时,它总是在我运行应用程序时发生。

所以我想知道如何发现这种情况发生在哪里。

这是我发生时收到的错误消息。

[Switching to thread 20483]
[Switching to thread 20483]
(gdb) continue
[Switching to thread 11523]
[Switching to thread 11523]
2011-11-18 16:37:45.301 [559:9e0b] bool _WebTryThreadLock(bool), 0x2e2710: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
[Switching to thread 20483]
[Switching to thread 20483]
Program received signal:  “EXC_BAD_ACCESS”.
kill
quit

之前我得到了更多这些,但我能够发现它们,但不是这个......

2 个答案:

答案 0 :(得分:0)

您可以在项目窗口下的菜单中尝试管理器,控制台会显示正在发生的事情。

答案 1 :(得分:0)

您还可以启用所谓的Zombies来帮助跟踪此类错误。使用Zombies,如果你释放它们,你的对象就不会被完全释放,所以当你引用一个“不存在”的对象时,它实际上仍然在那里。 通常,您可以看到导致EXC_BAD_ACCESS的代码的确切行。