Thursday, October 20, 2011

iPhone | code crash : Mutated Collection during fast enumeration

If you are going to use , fast enumeration in your objective C code?
for (id {object} in {collection}) {...}" )

You shall not be able to modify the collection (add or remove) during enumeration.
Because, thread will have a lock on the resources being used.

for that either go with the :

1) for(NSUInteger i=0 ; i< [ {collection} length];i++){…}
2) Put the add/remove logic in another thread

Hope this helps!

No comments:

Post a Comment