问题描述
有没有人可以在这里帮助我,为什么我会在我的代码中突然崩溃 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'而终止应用,原因:' * **收集< __ NSArrayM:0x610000859410>在枚举时发生了突变。'*
在使用快速枚举时,您必须尝试更改数组。
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崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!