Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSFastEnumerationMutationHandler crash

Tags:

iphone

crash

Could anyone possibly help me here, why I am getting NSFastEnumerationMutationHandler crash all of a sudden in my code. I am all but blank why this crash poped up all of a sudden and how to squash this one.

Thanks.

like image 519
Manoj Avatar asked Jul 07 '11 09:07

Manoj


1 Answers

Crash Error: **** Terminating app due to uncaught exception 'NSGenericException', reason: '* **Collection <__NSArrayM: 0x610000859410> was mutated while being enumerated.'*

You must be trying to change an array while you using fast enumeration.

Example

for ( id anObject in anArray ) {
    if ( /* anObject satisfies some condition */ ) {
        [anArray removeObject:anObject];
    }
}

That shouldn't be done. Use a different array or probably filteredArrayUsingPredicate: method to filter. Remedy, however, depends on what you're trying to do.

like image 184
Deepak Danduprolu Avatar answered Sep 23 '22 13:09

Deepak Danduprolu