Deprecated NSArray Methods

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

Deprecated in iOS 4.0


Copies all the objects contained in the array to aBuffer. (Deprecated in iOS 4.0. Use getObjects:range: instead.)

- (void)getObjects:(id __unsafe_unretained [])objects

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


The method copies into aBuffer all the objects in the array; the size of the buffer must therefore be at least the count of the array 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]);
Special Considerations

This deprecated method is unsafe because it could potentially cause buffer overruns.

  • Available in iOS 2.0 and later.
  • Deprecated in iOS 4.0.
Declared In