致命异常:NSGenericException ***集合< __ NSArrayM:0x17165f620>在被列举时被突变

时间:2017-05-12 10:13:32

标签: exception collections nsarray

我从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;
}

0 个答案:

没有答案