ftp.nice.ch/peanuts/GeneralData/Documents/openstep/OpenStepSpec_rtf.tar.gz#/OpenStepSpec_rtf/FoundationKit/Classes/NSMutableArray.rtf

This is NSMutableArray.rtf in view mode; [Download] [Up]

paperh18648 margl-907 margr0 margt0 margb0 fi0 ri0 ql sb0 f1 fs24 Copyright f3 'e3f1 1994 by NeXT Computer, Inc.  All Rights Reserved.

s4 li100 fi0 ri1007 ql f0 b fs36 fs100 
fs36 NSMutableArray 
pard s11 li2872 fi-2771 ri1007 ql tx2872 f1 b0 fs28 fs48 
fs28 f0 b fs24 Inherits From:tab b0 fs28 f1 NSArray : NSObject
fs20 
fs28 s6 f0 b fs24 Conforms To:tab b0 fs28 f1 NSCoding, NSCopying, NSMutableCopying (NSArray)
fi0 NSObject (NSObject)
fs20 
fs28 s7 fi-2771 f0 b fs24 Declared In:tab b0 fs28 f1 Foundation/NSArray.h 
fs20 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs28 fs20 
fs28 Class Description
fs14 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs2 
fs28 The NSMutableArray class declares the programmatic interface to objects that manage a modifiable array of objects. This class adds insertion and deletion operations to the basic array-handling behavior it inherits from NSArray. 
fs16 
fs28 The array operations that NSMutableArray declares are conceptually based on these three methods:
fs16 
fs28 pard s17 li854 fi0 ri1007 ql tx4509 tx10180 addObject:
fi0 replaceObjectAtIndex:withObject:
fi0 removeLastObject
fs6 
fs28 pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 fs10 
fs28 The other methods in its interface provide convenient ways of inserting an object into a specific slot in the array and of removing an object based on its identity or position in the array.
fs16 
fs28 When an object is removed from a mutable array it receives a b releaseb0  message, which can cause it to be deallocated. Note that if your program keeps a reference to such an object, the reference may become invalid unless you remember to send the object a b retainb0  message before it'27s removed from the array. For example, the third statement below could result in a run-time error, except for the b retainb0  message in the first statement:
fs16 
fs28 pard s5 li1231 fi0 ri1007 ql f2 fs20 id anObject = [[anArray objectAtIndex:0] retain];
[anArray removeObjectAtIndex:0];
[anObject i someMessagei0 ];
s15 li477 fi753 fi0 f0 b fs24 fs20 
fs24 Implementing Subclasses of NSMutableArray
pard s1 li477 fi0 ri1007 ql tx2494 tx2872 tx3250 f1 b0 fs28 fs16 
fs28 Although conceptually the interface to the NSMutableArray class is based on the three methods listed above, for performance reasons two others'd0b insertObject:atIndex:b0  and b removeObjectAtIndex:b0 'd0also directly access the object'27s data. These two methods could be implemented using the methods listed above but in doing so would incur unnecessary overhead from the b retainb0  and b releaseb0  messages that objects would receive as they are shifted to accommodate the insertion or deletion of an element. Thus, if you create a subclass of NSMutableArray, you should override all five primitive methods so that the other methods in NSMutableArray'27s interface work properly.
fs16 
fs28 pard s16 li100 fi0 ri1007 ql f0 b fs24 
fs28 Creating and Initializing an NSMutableArray
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 + (id)b allocWithZone:b0 (NSZone *)i zonei0 tab Creates and returns an uninitialized NSMutableArray in i zone.
fi-6552 i0 fs16 
fs28 fi-6552 + (id)b arrayWithCapacity:b0 (unsigned int)i aNumItemsi0 tab Creates and returns an NSMutableArray, giving it enough allocated memory to hold i numItemsi0  objects.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (id)b initWithCapacity:b0 (unsigned int)i aNumItemsi0 tab Initializes a newly allocated NSMutableArray, giving it enough memory to hold i numItemsi0  objects.
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Adding Objectstab 
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (void)b addObject:b0 (id)i anObjecti0 tab Inserts i anObjecti0  at the end of the array. Raises NSInvalidArgumentException if i anObjecti0  is b nilb0 .
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b addObjectsFromArray:b0 (NSArray *)i anotherArray
s9 li7030 fi-6553 fi-5796 i0 tab Adds the objects contained in i anotherArrayi0  to the end of the receiver'27s array.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b insertObject:b0 (id)i anObjecti0  b atIndex:b0 (unsigned int)i index
s9 li7030 fi-6553 fi-5796 i0 tab Insertsi  i0 anObject into the array at i indexi0 . Raises
tab tab NSInvalidArgumentException if i anObjecti0  is b nilb0 . Raises NSRangeException if i indexi0  is outside of the bounds of the array.tab 
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Removing Objects
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (void)b removeAllObjectsb0 tab Empties the array of all its elements.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeLastObjectb0 tab Removes the last object in the array and sends it a b releaseb0  message. Raises NSRangeException if there are no objects in the array.
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeObject:b0 (id)i anObjecti0 tab Removes all occurrences of i anObjecti0 . b isEqual:b0  is used to test for i anObjecti0 .
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeObjectAtIndex:b0 (unsigned int)i indexi0 tab Removes the object at i indexi0  and moves all elements beyond i indexi0  up one slot to fill the gap. Raises NSRangeException if i indexi0  is outside of the bounds of the array.tab 
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeObjectIdenticalTo:b0 (id)i anObjecti0 tab Removes all elements having the same b idb0  as i anObjecti0 .
fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeObjectsFromIndices:b0 (unsigned int*)i indicesi0 tab 
s9 li7030 fi-6553 fi-5796 b numIndices:b0 (unsigned int)i counti0 tab Removes objects at the positions specified in the i indicesi0  array, which has i counti0  elements. Raises NSRangeException if any of the i indicesi0  is outside of the bounds of the array. This method is provided for efficiency reasons; it will not work if the receiver is a proxy to an array in another process.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b removeObjectsInArray:b0 (NSArray *)i otherArray
s9 li7030 fi-6553 fi-5796 i0 tab Removes from the receiver the objects found in i otherArrayi0 .
pard s16 li100 fi0 ri1007 ql f0 b fs48 
fs28 Replacing Objects
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (void)b replaceObjectAtIndex:b0 (unsigned int)i indexi0 tab Replaces the object at i indexi0  with i anObjecti0 . Raises
s9 li7030 fi-6553 fi-5796  b withObject:b0 (id)i anObjecti0 tab tab NSInvalidArgumentException if i anObjecti0  is b nilb0 . Raises NSRangeException if i indexi0  is not within the bounds of the array.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b setArray:b0 (NSArray *)i otherArrayi0 tab Sets the contents of the receiver to the elements in i otherArray
pard s16 li100 fi0 ri1007 ql f0 b i0 fs48 
fs28 Sorting Elements
fs14 
fs28 pard s8 li7029 fi-6552 ri1007 ql tx6652 tx7030 f1 b0 fs2 
fs28 fi-6552 {f3 -} (void)b sortUsingFunction:b0 (int (*)(id i fs28 element1i0 fs28 , id i fs28 element2i0 fs28 ,void *i fs28 userDatai0 fs28 ))i fs28 comparator
s9 li7030 fi-6553 fi-5796 i0 fs28 b context:b0 (void *)i contexti0 tab Sorts the receiver'27s elements in ascending order as defined by the comparison function i comparatori0 . i contexti0  is passed as the function'27s third argument.
s8 li7029 fi-5794 fi-6552 fs16 
fs28 fi-6552 {f3 -} (void)b sortUsingSelector:b0 (SEL)i fs28 comparatori0 fs28 tab Sorts the receiver'27s elements in ascending order as defined by the comparison method i comparatori0 .
s9 li7030 fi-6553 fi-5796 
}

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.