5
<a href ="NSArchiver.html">[Previous] </a>
6
<a href ="Base.html">[Up] </a>
7
<a href ="NSAssertionHandler.html">[Next] </a>
11
<dt><a href ="http://www.gnustep.org/developers/whoiswho.html">Richard Frith-Macdonald</a>
13
<dt><a href ="">Pierre-Yves Rivaille</a>
16
<p>Version: $Revision: 1.13 $</p>
17
<p>Date: $Date: 2001/12/12 14:10:12 $</p>
18
<h2><a name ="cont-0">NSArray</a></h2>
19
<h2><a name ="NSArray">NSArray</a></h2>
20
<p><b>Declared in: </b> Foundation/NSArray.h</p>
21
<p><b>Inherits from: </b> NSObject</p>
22
<p><b>Conforms to: </b> NSCoding
27
<h2>Instance Variables </h2>
32
<li ><a href ="NSArray.html#method-0">+allocWithZone:</a>
33
<li ><a href ="NSArray.html#method-1">+array</a>
34
<li ><a href ="NSArray.html#method-2">+arrayWithArray:</a>
35
<li ><a href ="NSArray.html#method-3">+arrayWithContentsOfFile:</a>
36
<li ><a href ="NSArray.html#method-4">+arrayWithObject:</a>
37
<li ><a href ="NSArray.html#method-5">+arrayWithObjects:</a>
38
<li ><a href ="NSArray.html#method-6">+arrayWithObjects:count:</a>
39
<li ><a href ="NSArray.html#method-7">-arrayByAddingObject:</a>
40
<li ><a href ="NSArray.html#method-8">-arrayByAddingObjectsFromArray:</a>
41
<li ><a href ="NSArray.html#method-9">-componentsJoinedByString:</a>
42
<li ><a href ="NSArray.html#method-10">-containsObject:</a>
43
<li ><a href ="NSArray.html#method-11">-count</a>
44
<li ><a href ="NSArray.html#method-12">-descriptionWithLocale:</a>
45
<li ><a href ="NSArray.html#method-13">-descriptionWithLocale:</a>
46
<li ><a href ="NSArray.html#method-14">-firstObjectCommonWithArray:</a>
47
<li ><a href ="NSArray.html#method-15">-getObjects:</a>
48
<li ><a href ="NSArray.html#method-16">-getObjects:range:</a>
49
<li ><a href ="NSArray.html#method-17">-indexOfObject:</a>
50
<li ><a href ="NSArray.html#method-18">-indexOfObject:range:</a>
51
<li ><a href ="NSArray.html#method-19">-indexOfObjectIdenticalTo:</a>
52
<li ><a href ="NSArray.html#method-20">-indexOfObjectIdenticalTo:range:</a>
53
<li ><a href ="NSArray.html#method-21">-initWithArray:</a>
54
<li ><a href ="NSArray.html#method-22">-initWithContentsOfFile:</a>
55
<li ><a href ="NSArray.html#method-23">-initWithObjects:</a>
56
<li ><a href ="NSArray.html#method-24">-initWithObjects:count:</a>
57
<li ><a href ="NSArray.html#method-25">-isEqualToArray:</a>
58
<li ><a href ="NSArray.html#method-26">-lastObject</a>
59
<li ><a href ="NSArray.html#method-27">-makeObjectsPerformSelector:</a>
60
<li ><a href ="NSArray.html#method-28">-makeObjectsPerformSelector:withObject:</a>
61
<li ><a href ="NSArray.html#method-29">-objectAtIndex:</a>
62
<li ><a href ="NSArray.html#method-30">-objectEnumerator</a>
63
<li ><a href ="NSArray.html#method-31">-pathsMatchingExtensions:</a>
64
<li ><a href ="NSArray.html#method-32">-reverseObjectEnumerator</a>
65
<li ><a href ="NSArray.html#method-33">-sortedArrayHint</a>
66
<li ><a href ="NSArray.html#method-34">-sortedArrayUsingFunction:context:</a>
67
<li ><a href ="NSArray.html#method-35">-sortedArrayUsingFunction:context:</a>
68
<li ><a href ="NSArray.html#method-36">-sortedArrayUsingSelector:hint:</a>
69
<li ><a href ="NSArray.html#method-37">-subarrayWithRange:</a>
70
<li ><a href ="NSArray.html#method-38">-writeToFile:atomically:</a>
71
<li ><a href ="NSArray.html#method-39">-writeToURL:atomically:</a>
73
<hr><h2>Class Methods </h2>
74
<h3><a name ="method-0">allocWithZone:</a></h3>
75
+ (id) <b>allocWithZone:</b> (NSZone*)zone;<br>
80
<h3><a name ="method-1">array</a></h3>
81
+ (id) <b>array</b>;<br>
83
Returns a new empty array.
86
<h3><a name ="method-2">arrayWithArray:</a></h3>
87
+ (id) <b>arrayWithArray:</b> (NSArray*)anArray;<br>
89
Returns a new array containing the same elements as anArray.
92
<h3><a name ="method-3">arrayWithContentsOfFile:</a></h3>
93
+ (id) <b>arrayWithContentsOfFile:</b> (NSString*)aPath;<br>
95
Returns a new array based upon the file located at aPath.
96
This file may be in property list format or in XML format (if XML is available).
97
This method returns nil if the file does not represent an array.
100
<h3><a name ="method-4">arrayWithObject:</a></h3>
101
+ (id) <b>arrayWithObject:</b> (id)anObject;<br>
103
Returns a new array containing only one object, anObject.
106
<h3><a name ="method-5">arrayWithObjects:</a></h3>
107
+ (id) <b>arrayWithObjects:</b> (id)firstObj,;<br>
109
Returns a new array containing the objects passed as arguments to the method. The order is preserved.
112
<h3><a name ="method-6">arrayWithObjects:count:</a></h3>
113
+ (id) <b>arrayWithObjects:</b> (id*)objects <b>count:</b> (unsigned)count;<br>
115
Returns a new array containing the objects that are in
116
the C-array objects and which size is count.
117
The order is preserved.
120
<hr><h2>Instances Methods </h2>
121
<h3><a name ="method-7">arrayByAddingObject:</a></h3>
122
- (NSArray*) <b>arrayByAddingObject:</b> (id)anObject;<br>
124
Returns a new array created by adding anObject at the end of seld. The order is respected.
127
<h3><a name ="method-8">arrayByAddingObjectsFromArray:</a></h3>
128
- (NSArray*) <b>arrayByAddingObjectsFromArray:</b> (NSArray*)otherArray;<br>
130
Returns a new array which is the concatenation of self and otherArray (in this precise order).
133
<h3><a name ="method-9">componentsJoinedByString:</a></h3>
134
- (NSString*) <b>componentsJoinedByString:</b> (NSString*)separator;<br>
136
Returns a string created by the concatenation of self's elements' description separated by the string separator.
137
The order is preserved.
140
<h3><a name ="method-10">containsObject:</a></h3>
141
- (BOOL) <b>containsObject:</b> (id)anObject;<br>
143
Returns YES if anObject belongs to self. No otherwise. The isEqual: method of anObject is used to test equality.
146
<h3><a name ="method-11">count</a></h3>
147
- (unsigned int) <b>count</b>;<br>
149
Returns the number of elements contained in self.
152
<h3><a name ="method-12">descriptionWithLocale:</a></h3>
153
- (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)locale;<br>
158
<h3><a name ="method-13">descriptionWithLocale:</a></h3>
159
- (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)locale;<br>
164
<h3><a name ="method-14">firstObjectCommonWithArray:</a></h3>
165
- (id) <b>firstObjectCommonWithArray:</b> (NSArray*)otherArray;<br>
167
Returns the first element of the array which can be found in otherArray.
168
Equality is tested with the isEqual method.
171
<h3><a name ="method-15">getObjects:</a></h3>
172
- (void) <b>getObjects:</b> (id*)aBuffer;<br>
174
This methods store all the elements of self inside aBuffer which is a C-array.
175
The order is preserved. You should get sure aBuffer's size is sufficient.
178
<h3><a name ="method-16">getObjects:range:</a></h3>
179
- (void) <b>getObjects:</b> (id*)aBuffer <b>range:</b> (NSRange)aRange;<br>
181
This methods store the elements of self in the range aRange inside aBuffer which is a C-array.
182
The order is preserved. You should get sure aBuffer's size is sufficient.
185
<h3><a name ="method-17">indexOfObject:</a></h3>
186
- (unsigned int) <b>indexOfObject:</b> (id)anObject;<br>
188
Returns the index of the first object of the array which is equal to anObject.
189
Equality is tested with the isEqual: method of anObject.
192
<h3><a name ="method-18">indexOfObject:range:</a></h3>
193
- (unsigned int) <b>indexOfObject:</b> (id)anObject <b>range:</b> (NSRange)aRange;<br>
195
Returns the index of the first object of the array which is equal to anObject and which is in aRange range.
196
Equality is tested with the isEqual: method of anObject.
199
<h3><a name ="method-19">indexOfObjectIdenticalTo:</a></h3>
200
- (unsigned int) <b>indexOfObjectIdenticalTo:</b> (id)anObject;<br>
202
Returns the index of the first object of the array which is physically equal to anObject.
203
Physical equality is tested with ==.
206
<h3><a name ="method-20">indexOfObjectIdenticalTo:range:</a></h3>
207
- (unsigned int) <b>indexOfObjectIdenticalTo:</b> (id)anObject <b>range:</b> (NSRange)aRange;<br>
209
Returns the index of the first object of the array which is physically equal to anObject and which is in aRange range.
210
Physical equality is tested with ==.
213
<h3><a name ="method-21">initWithArray:</a></h3>
214
- (id) <b>initWithArray:</b> (NSArray*)anArray;<br>
216
Initialize the array with the content of anArray. The order is preserved.
220
<h3><a name ="method-22">initWithContentsOfFile:</a></h3>
221
- (id) <b>initWithContentsOfFile:</b> (NSString*)aPath;<br>
223
Initialize the array based upon the file located at aPath.
224
This file may be in property list format or in XML format (if XML is available).
225
If the file does not represent an array, self is left uninitialized and nil is returned.
226
Otherwise self is returned.
229
<h3><a name ="method-23">initWithObjects:</a></h3>
230
- (id) <b>initWithObjects:</b> (id)firstObj,;<br>
232
Initialize the array with the objects passed as arguments. The order is preserved.
234
NSInvalidArgumentException is raised if nil is one of the objects.
237
<h3><a name ="method-24">initWithObjects:count:</a></h3>
238
- (id) <b>initWithObjects:</b> (id*)objects <b>count:</b> (unsigned)count;<br>
240
Initialize the array with the objects contained in the
241
C-array argument which size is count.
242
The order is preserved.
244
NSInvalidArgumentException is raised if nil is one of the objects.
247
<h3><a name ="method-25">isEqualToArray:</a></h3>
248
- (BOOL) <b>isEqualToArray:</b> (NSArray*)otherArray;<br>
250
Returns YES if the two arrays contain the same elements,
251
i.e. the two arrays have the same length and <br>
252
for i from 0 to length - 1,
253
[[self objectAtIndex: i] isEqual: [anArray objectAtIndex: i]] returns YES.
256
<h3><a name ="method-26">lastObject</a></h3>
257
- (id) <b>lastObject</b>;<br>
259
Returns the last element of the array. If the array is empty, returns nil.
262
<h3><a name ="method-27">makeObjectsPerformSelector:</a></h3>
263
- (void) <b>makeObjectsPerformSelector:</b> (SEL)aSelector;<br>
265
Perform aSelector on every object of the array.
266
This is done sequentially from the last to the first object.
269
<h3><a name ="method-28">makeObjectsPerformSelector:withObject:</a></h3>
270
- (void) <b>makeObjectsPerformSelector:</b> (SEL)aSelector <b>withObject:</b> (id)anObject;<br>
272
Perform aSelector with the argument anObject on every object of the array.
273
This is done sequentially from the last to the first object.
276
<h3><a name ="method-29">objectAtIndex:</a></h3>
277
- (id) <b>objectAtIndex:</b> (unsigned int)index;<br>
279
Returns located in the array at position index.
280
Raise NSRangeException if index is out of bounds
283
<h3><a name ="method-30">objectEnumerator</a></h3>
284
- (NSEnumerator*) <b>objectEnumerator</b>;<br>
286
Returns an enumerator describing the array sequentially
287
from the first to the last element.<br>
288
If you use a mutable subclass of NSArray,
289
you should not modify the array during enumeration
292
<h3><a name ="method-31">pathsMatchingExtensions:</a></h3>
293
- (NSArray*) <b>pathsMatchingExtensions:</b> (NSArray*)filterTypes;<br>
295
Returns all the elements of the array which are NSString which
296
extensions are within the filterTypes NSArray.
299
<h3><a name ="method-32">reverseObjectEnumerator</a></h3>
300
- (NSEnumerator*) <b>reverseObjectEnumerator</b>;<br>
302
Returns an enumerator describing the array sequentially
303
from the last to the first element.<br>
304
If you use a mutable subclass of NSArray,
305
you should not modify the array during enumeration
309
<h3><a name ="method-33">sortedArrayHint</a></h3>
310
- (NSData*) <b>sortedArrayHint</b>;<br>
312
Returns nil. Does not do anything. TODO
315
<h3><a name ="method-34">sortedArrayUsingFunction:context:</a></h3>
316
- (NSArray*) <b>sortedArrayUsingFunction:</b> (int(*)(id,id,void*))comparator <b>context:</b> (void*)context;<br>
321
<h3><a name ="method-35">sortedArrayUsingFunction:context:</a></h3>
322
- (NSArray*) <b>sortedArrayUsingFunction:</b> (int(*)(id,id,void*))compare <b>context:</b> (void*)context;<br>
327
<h3><a name ="method-36">sortedArrayUsingSelector:hint:</a></h3>
328
- (NSArray*) <b>sortedArrayUsingSelector:</b> (SEL)comparator <b>hint:</b> (NSDate*)hint;<br>
333
<h3><a name ="method-37">subarrayWithRange:</a></h3>
334
- (NSArray*) <b>subarrayWithRange:</b> (NSRange)range;<br>
336
Returns a new array which contains self's elements located in range.
337
The order is preserved.
340
<h3><a name ="method-38">writeToFile:atomically:</a></h3>
341
- (BOOL) <b>writeToFile:</b> (NSString*)path <b>atomically:</b> (BOOL)flag;<br>
346
<h3><a name ="method-39">writeToURL:atomically:</a></h3>
347
- (BOOL) <b>writeToURL:</b> (NSURL*)url <b>atomically:</b> (BOOL)flag;<br>