我从MutableArray中检索项目时遇到致命异常。应用程序崩溃了。
错误:
Fatal Exception: NSGenericException
*** Collection <__NSArrayM: 0x17165f620> was mutated while being enumerated.
Raw Text
0 CoreFoundation __exceptionPreprocess
1 libobjc.A.dylib objc_exception_throw
2 CoreFoundation -[NSException name]
3 BroadCastApp GPBroadCastService.m line 624
-[GPBroadCastService getSubscribedItemFromBroadcastedGroup:]
代码:
- (id)getSubscribedItemFromBroadcastedGroup:(id)group
{
id item = nil;
NSArray *broadcastedGroupItems = [self getBroadcasetedGroupItems];//Returns MutableArray
for (item in [broadcastedGroupItems copy]) {
if ([[item valueForKey:@"groupId"] isEqualToString:group.groupId])
{
break;
}
}
return item;
}