NSFastEnumerationMutationHandler 崩溃 [英] NSFastEnumerationMutationHandler crash

查看:21
本文介绍了NSFastEnumerationMutationHandler 崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以在这里帮助我,为什么我的代码中突然出现 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆