Avoiding “NSArray was mutated while being enumerated”

后端 未结 10 1777
傲寒
傲寒 2020-11-29 06:07

I have an NSMutableArray that stores mousejoints for a Box2d physics simulation. When using more than one finger to play I\'ll get exceptions stating

10条回答
  •  春和景丽
    2020-11-29 06:07

    for(MyObject *obj in objQueue)
    {
    //[objQueue removeObject:someof];//NEVER removeObject in a for-in loop
        [self dosomeopearitions];
    }
    
    //instead of remove outside of the loop
    [objQueue removeAllObjects];
    

提交回复
热议问题