Deprecated NSArray Methods
A method identified as deprecated has been superseded and may become unsupported in the future.
Deprecated in iOS 4.0
getObjects:
Copies all the objects contained in the array to aBuffer. (Deprecated in iOS 4.0. Use getObjects:range: instead.)
Parameters
- aBuffer
A C array of objects of size at least the count of the array.
Discussion
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]); |
} |
free(objects); |
Special Considerations
This deprecated method is unsafe because it could potentially cause buffer overruns.
Availability
- Available in iOS 2.0 and later.
- Deprecated in iOS 4.0.
See Also
Declared In
NSArray.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-12-13)