Posted By

saturngod on 10/15/10


Tagged

nsmutablearray


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bobbym245
cnathan


NSMutableArray Move


 / Published in: Objective C
 

  1. - (void)moveObjectFromIndex:(NSUInteger)from toIndex:(NSUInteger)to
  2. {
  3. if (to != from) {
  4. id obj = [addItemsList objectAtIndex:from];
  5. [obj retain];
  6. [addItemsList removeObjectAtIndex:from];
  7. if (to >= [addItemsList count]) {
  8. [addItemsList addObject:obj];
  9. } else {
  10. [addItemsList insertObject:obj atIndex:to];
  11. }
  12. [obj release];
  13. }
  14. }

Report this snippet  

You need to login to post a comment.