间歇性NSArray索引异常

时间:2012-09-28 16:53:27

标签: ios xcode debugging

我发生了一次至少每天发生一次的撞车事故,我似乎无法指责。它似乎发生在我随机的时刻,我无法追踪堆栈,以了解它为什么会发生。如果有人能指出我正确的方向,甚至向我展示一些关于如何正确追踪完美价值的在线文档和教程。我理解的最多的是有些东西试图访问数组中的索引,但我无法弄清楚这个数组是什么样的。我已经在下面的输出窗口中包含了这些信息:

2012-09-28 12:45:26.884 TestApp[1683:c07] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1bdd052 0x19ccd0a 0x1bc9db8 0x29522 0x23e76 0x22bed 0x21e36 0xdfee 0xdba8 0xd3cc 0x1bdee72 0x13339ef 0x1bb197f 0x1b14b73 0x1b14454 0x1b13db4 0x1b13ccb 0x2692879 0x269293e 0xa1ba9b 0x2ded 0x2d25)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c
(gdb) bt
#0  0x98468a6a in __pthread_kill ()
#1  0x98554acf in pthread_kill ()
#2  0x9858b4f8 in abort ()
#3  0x021cbe78 in abort_message ()
#4  0x021c989e in default_terminate ()
#5  0x019ccf4b in _objc_terminate ()
#6  0x021c98de in safe_handler_caller ()
#7  0x021c9946 in std::terminate ()
#8  0x021cab3e in __cxa_rethrow ()
#9  0x019cce49 in objc_exception_rethrow ()
#10 0x01b13e10 in CFRunLoopRunSpecific ()
#11 0x01b13ccb in CFRunLoopRunInMode ()
#12 0x02692879 in GSEventRunModal ()
#13 0x0269293e in GSEventRun ()
#14 0x00a1ba9b in UIApplicationMain ()
#15 0x00002ded in main (argc=1, argv=0xbffff39c) at /Users/seb/Desktop/Development/main.m:14

1 个答案:

答案 0 :(得分:2)

您需要使用Xcode调试器:

  • 点击工具栏中的“断点”按钮:

Breakpoints button

  • 点击左侧窗格中的“断点”选项:

enter image description here

  • 点按左下角的“+”按钮,然后选择“添加例外断点”:

enter image description here

  • 在显示的视图中点击完成,您会看到类似的内容(最上面一个被禁用):

enter image description here

  • 确保您的应用方案已启用lldb:

enter image description here