检测有问题的数组(调试模式)

时间:2014-12-16 13:13:57

标签: ios objective-c xcode debugging swift

当我调用一些方法时,我的应用程序正在粉碎

我可以看到错误消息,我理解它的内容,但我不知道如何通过消息检测出问题的阵列。 我在项目中有很多数组。 我如何知道问题的来源?

这是消息:

2014-12-16 15:07:01.830 myApp[2776:1237923] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x2a3eae3f 0x37a98c8b 0x2a2ffc49 0x114c07 0x2d8e515d 0x2d8e3835 0x2d8df47d 0x2d885b37 0x2d2adccd 0x2d2a96b5 0x2d2a953d 0x2d2a8f21 0x2d2a8d25 0x2d2a2bfd 0x2a3b15cd 0x2a3aec8b 0x2a3af093 0x2a2fd621 0x2a2fd433 0x316ab0a9 0x2d8e7809 0x12fee5 0x38018aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException

2 个答案:

答案 0 :(得分:4)

要处理所有异常,请从Xcode单击显示断点导航

单击底部的+按钮,然后从弹出窗口单击添加例外断点。

enter image description here

这将为应用程序添加异常断点,尝试再次运行,如果引发任何运行时异常,执行将停止。

enter image description here

如果这样做无效,请为项目启用zombie环境,从此主题中查看 -

<强> How to set exception breakpoint from Xcode

答案 1 :(得分:1)

在Xcode中启用Zombie Object以获得更好的错误跟踪。

启用

  • 按Command + Option + R
  • 在“诊断”标签下 - &gt;内存管理
  • 选中&#34;启用Zombie Object&#34;

希望这有助于