NSFastEnumerationMutationHandler崩溃

Man*_*noj 5 iphone crash

有谁可能在这里帮助我,为什么NSFastEnumerationMutationHandler我的代码突然崩溃了.我几乎是空白的,为什么这次崩溃突然加剧,以及如何压制这一次.

谢谢.

Dee*_*olu 13

崩溃错误: ****由于未捕获的异常'NSGenericException'而终止应用程序,原因:' ***集合<__ NSArrayM:0x610000859410>在枚举时发生了变异.'*

在使用快速枚举时,您必须尝试更改数组.

for ( id anObject in anArray ) {
    if ( /* anObject satisfies some condition */ ) {
        [anArray removeObject:anObject];
    }
}
Run Code Online (Sandbox Code Playgroud)

不应该这样做.使用不同的数组或可能的filteredArrayUsingPredicate:方法进行过滤.然而,补救措施取决于你想要做什么.