NSMutableArray

NSMutableArray Mac OS X 10.0

This class extends the API of NSArray to allow for mutable, ordered collections of objects. NSMutableArray provides five primitive methods, which form the basis for the rest of its methods: addObject:, insertObject:atIndex:, removeLastObject, removeObjectAtIndex:, and replaceObjectAtIndex:withObject:. When an object is added to an array, the array asserts some ownership over the object by sending it a retain message. Likewise, when an object is removed from an array, it is sent a release message by the array.

NSMutableArray is toll-free bridged with the Core Foundation type CFArray. As such, NSMutableArray objects can be used interchangeably with the CFArray pointer type, CFArrayRef.

figs/cocn_1357.gif

@interface NSMutableArray : NSArray
 // Initializers
   - (id)initWithCapacity:(unsigned)numItems;
 // Accessor Methods
   - (void)setArray:(NSArray *)otherArray;
 // Class Methods
   + (id)arrayWithCapacity:(unsigned)numItems;
 // Instance Methods
   - (void)addObject:(id)anObject;
   - (void)addObjectsFromArray:(NSArray *)otherArray;
   - (void)exchangeObjectAtIndex:(unsigned)idx1 withObjectAtIndex:(unsigned)idx2;
   - (void)insertObject:(id)anObject atIndex:(unsigned)index;
   - (void)removeAllObjects;
   - (void)removeLastObject;
   - (void)removeObject:(id)anObject;
   - (void)removeObject:(id)anObject inRange:(NSRange)range;
   - (void)removeObjectAtIndex:(unsigned)index;
   - (void)removeObjectIdenticalTo:(id)anObject;
   - (void)removeObjectIdenticalTo:(id)anObject inRange:(NSRange)range;
   - (void)removeObjectsFromIndices:(unsigned *)indices numIndices:(unsigned)count;
   - (void)removeObjectsInArray:(NSArray *)otherArray;
   - (void)removeObjectsInRange:(NSRange)range;
   - (void)replaceObjectAtIndex:(unsigned)index withObject:(id)anObject;
   - (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray;
   - (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray
        range:(NSRange)otherRange;
   - (void)sortUsingFunction:(int (*)(id, id, void *))compare
     context:(void *)context;
   - (void)sortUsingSelector:(SEL)comparator;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes