iphone - Objective-C NSMutableArray mutated while being enumerated? -



iphone - Objective-C NSMutableArray mutated while being enumerated? -

i kinda stumbled error seek remove objects nsmutablearray while other objects beingness added elsewhere. maintain simple, have no clue on how prepare it. here i'm doing:

i have 4 timers calling 4 different methods adds object same array. now, when press button, need remove objects in array (or @ to the lowest degree some). tried first invalidate 4 timers, , work want array, , fire timers. thought would've worked since not using timers anymore enumerate through array, seemingly doesn't work.

any suggestions here?

it's nil timers. because (i assume) timers working on same thread modifying method don't need stop , start them. ios doesn't utilize interrupt model timer callbacks, have wait turn other event :)

you're doing like

for (id object in myarray) if (somecondition) [myarray removeobject:object];

you can't edit mutable array while you're going through need create temporary array hold things want remove

// find things remove nsmutablearray *todelete = [nsmutablearray array]; (id object in myarray) if (somecondition) [todelete addobject:object]; // remove them [myarray removeobjectsinarray:todelete];

iphone objective-c xcode

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -