0

我经常被这个问题困扰,*由于未捕获的异常'NSRangeException'而终止应用程序,原因:'* -[__NSArrayM objectAtIndex:]: index 2 beyond bounds [0 .. 1]'

这使我的应用程序崩溃。我之前没有遇到过这个问题,但是有一天它开始出现,但是由于我有这么多数组,我什至不知道它来自哪里。有没有办法告诉应用程序不要因为这个错误而崩溃,或者找到导致问题的数组?

顺便说一句,每次我运行代码时,我都会这样做:

[messagename removeAllObjects];
[messageframe removeAllObjects];
[messagetext removeAllObjects];
[MapViewArray removeAllObjects];
[DeleteButtonArray removeAllObjects];

NSFileManager *fileManager = [NSFileManager defaultManager];
[fileManager removeItemAtPath:reloadPath error:NULL];
[fileManager removeItemAtPath:reloadInfoPath error:NULL];
[fileManager removeItemAtPath:uploadPath error:NULL];
[fileManager removeItemAtPath:uploadPathMap error:NULL];

这应该清除所有数组...

4

2 回答 2

3

您可以将断点设置为特定异常或所有异常。
- 打开断点导航器 ( CMD+ 6)
- 单击+底部的符号
- 添加异常断点
- 可选择仅选择 Objective-C 异常

检查苹果文档

于 2012-07-29T09:33:37.590 回答
1

在 Xcode 中,您可以在“所有 Objective-C 异常”上设置异常断点。然后调试器将在异常发生时中断,您可以看到它发生在哪里。

于 2012-07-29T09:33:32.757 回答