Deprecated NSArray Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in Mac OS X v10.6

getObjects:

Copies all the objects contained in the receiver to aBuffer. (Deprecated in Mac OS X v10.6.)

- (void)getObjects:(id *)aBuffer

Parameters
aBuffer

A C array of objects of size at least the count of the receiver.

Discussion

The method copies into aBuffer all the objects in the receiver; the size of the buffer must therefore be at least the count of the receiver multiplied by the size of an object reference, as shown in the following example (note that this is just an example, you should typically not create a buffer simply to iterate over the contents of an array):

NSArray *mArray = // ...;
id *objects;
 
NSUInteger count = [mArray count];
objects = malloc(sizeof(id *) * count);
 
[mArray getObjects:objects];
 
for (i = 0; i < count; i++) {
    NSLog(@"object at index %d: %@", i, objects[i]);
}
free(objects);
Availability
See Also
Declared In
NSArray.h


© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-11-17)