Objective-C code hall of shame

Written by

in

,
Reading Time: < 1 minute

Last Updated on May 17, 2013 by stlplace

Today I found out I made a dumb mistake while deleting an NSMutableArray.

for(int ii=0; ii<[myNSMutableArray count]; ii++) { myNSMutableArray removeObjectAtIndex:ii]; } The reason being it will get confused about the elements (index) during the loop. The correct way is to use removeAllObjects method.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *