Objective-C NSMutableArray mutated while being enumerated?

It’s nothing to do with your timers. Because (I assume) your timers are all working on the same thread as your modifying method you don’t need to stop and start them. iOS doesn’t use an interrupt model for timer callbacks, they have to wait their turn just like any other event 🙂

You’re probably doing something like

for (id object in myArray)
   if (someCondition)
       [myArray removeObject:object];

You can’t edit a mutable array while you’re going through it so you need to make a temporary array to hold the things you want to remove

// Find the things to remove
NSMutableArray *toDelete = [NSMutableArray array];
for (id object in myArray)
   if (someCondition)
       [toDelete addObject:object];

// Remove them
[myArray removeObjectsInArray:toDelete];

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)