Objective-C code hall of shame

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.

Leave a Reply