NSFastEnumerationMutationHandler 崩溃 [英] NSFastEnumerationMutationHandler crash
问题描述
任何人都可以在这里帮助我,为什么我的代码中突然出现 NSFastEnumerationMutationHandler
崩溃.我几乎一无所知,为什么突然出现这个崩溃以及如何压扁这个.
Could anyone possibly help me here, why I am getting NSFastEnumerationMutationHandler
crash all of a sudden in my code. I am all but blank why this crash poped up all of a sudden and how to squash this one.
谢谢.
推荐答案
崩溃错误:**** 由于未捕获的异常NSGenericException"而终止应用程序,原因:* **Collection <__NSArrayM:0x610000859410> 在枚举时发生了变异.'*
Crash Error: **** Terminating app due to uncaught exception 'NSGenericException', reason: '* **Collection <__NSArrayM: 0x610000859410> was mutated while being enumerated.'*
您必须在使用快速枚举时尝试更改数组.
You must be trying to change an array while you using fast enumeration.
示例
for ( id anObject in anArray ) {
if ( /* anObject satisfies some condition */ ) {
[anArray removeObject:anObject];
}
}
不应该这样做.使用不同的数组或可能的 filteredArrayUsingPredicate:
方法进行过滤.但是,补救措施取决于您要执行的操作.
That shouldn't be done. Use a different array or probably filteredArrayUsingPredicate:
method to filter. Remedy, however, depends on what you're trying to do.
这篇关于NSFastEnumerationMutationHandler 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!