Posted By

suibhne on 06/13/10


Tagged

Objective-c iphone nsmutablearray


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
rvachere
cnathan


NSMutableArray Loop


 / Published in: Objective C
 

Just a simple loop around an NSMutableArray, but also removing an item if need be.

  1. NSMutableArray *discardedItems = [NSMutableArray array];
  2. SomeObjectClass *item;
  3.  
  4. for (item in originalArrayOfItems) {
  5. if ([item shouldBeDiscarded])
  6. [discardedItems addObject:item];
  7. }
  8.  
  9. [originalArrayOfItems removeObjectsInArray:discardedItems];

Report this snippet  

You need to login to post a comment.