0

我已经检查了如何解决此问题的示例,但我仍然面临它..

我的代码是

NSEnumerator *enu= [obstacles objectEnumerator];
    NSMutableArray *delete = [[NSMutableArray alloc] init];

    Object *obj;
    while ((obj=[enu nextObject])!=nil)
    {

        if ([obj isKindOfClass: [BObject class]] &&  CGPointEqualToPoint(obj.position, point)    ) {
            [view.objects removeObject: obj];
            //[obstacles removeObject: obj]; 
            [delete addObject:obj];
            }
    }


    [obstacles removeObjectsInArray:delete];
    [delete release];

错误是*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x6a97ba0> was mutated while being enumerated.'

obstacles更新:如果我的数组中只有一个对象,我的代码就可以工作。它因多个对象而失败..

4

0 回答 0