gpt4 book ai didi

ios - 我如何确定 "NSArrayM was mutated while being enumerated"来自哪里

转载 作者:行者123 更新时间:2023-11-28 19:04:20 30 4
gpt4 key购买 nike

我有时会遇到这个错误:

*** Terminating app due to uncaught exception 'NSGenericException', reason: 
'*** Collection <__NSArrayM: 0x170057580> was mutated while being enumerated.'

我知道我在使用快速枚举时改变了一个数组,但我不知道如何确定哪里发生了这个问题。堆栈跟踪完全没有显示任何内容,除了随机设置断点和猜测直到我找到它之外,我想不出一个好方法来将发生这种情况的位置归零。

我可以使用某种断点魔法让编译器告诉我发生这种情况的位置吗?或者我可以使用 NSZombies 以某种方式识别它吗?任何帮助将不胜感激。

最佳答案

查看如何设置异常断点:

https://developer.apple.com/library/ios/recipes/xcode_help-breakpoint_navigator/articles/adding_an_exception_breakpoint.html

但是在最新的Xcode中你只需要做这些步骤:

In the bottom-left corner of the breakpoints navigator, click the Add button.

Choose Add Exception Breakpoint.

然后您可以在断点导航器中得到它

enter image description here

您的代码现在会在抛出异常时中断,而不是在捕获异常时中断。您应该能够导航调用堆栈以查看代码中发生异常的位置。

关于ios - 我如何确定 "NSArrayM was mutated while being enumerated"来自哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21833315/

30 4 0