GenericException : Collection was mutated while being enumerated
我已经搜索了这个问题,我知道是由于数组在枚举时被操纵而引起的。在我的代码的前面,我在使用:
1 2 3 4 5 6 7 8 | -(BOOL)busy { for(DataRequest* request in self.active) if(!request.invisible) return YES; return NO; } |
当从服务器加载数据时,经常会调用
和
1 2 3 4 5 6 7 8 9 | -(BOOL)busy { self.tempActive = self.active; for(DataRequest* request in _tempActive) if(!request.invisible) return YES; return NO; } |
但是我仍然遇到同样的异常。我在做什么错,有什么想法吗?这是唯一使用
我得到的异常是:
1 | *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x9ec8f60> was mutated while being enumerated.' |
您需要了解类和堆栈对象(例如int和事物)之间的区别。如果某类与某类相等,则将其复制为类。您需要改用