Categories
Fun iPhone app

Objective-C code hall of shame

Reading Time: < 1 minute

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

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