Class

NSPointerArray

A collection similar to an array, but with a broader range of available memory semantics.

Declaration

@interface NSPointerArray : NSObject

Overview

The pointer array class is modeled after NSArray, but can also hold nil values. You can insert or remove nil values which contribute to the array's count.

A pointer array can be initialized to maintain strong or weak references to objects, or according to any of the memory or personality options defined by NSPointerFunctionsOptions.

The NSCopying and NSCoding protocols are applicable only when a pointer array is initialized to maintain strong or weak references to objects.

When enumerating a pointer array with NSFastEnumeration using for...in, the loop will yield any nil values present in the array. See Fast Enumeration Makes It Easy to Enumerate a Collection in Programming with Objective-C for more information.

Subclassing Notes

NSPointerArray is not suitable for subclassing.

Topics

Creating and Initializing a New Pointer Array

- initWithOptions:

Initializes the receiver to use the given options.

- initWithPointerFunctions:

Initializes the receiver to use the given functions.

+ pointerArrayWithOptions:

Returns a new pointer array initialized to use the given options.

+ pointerArrayWithPointerFunctions:

A new pointer array initialized to use the given functions.

+ strongObjectsPointerArray

Returns a new pointer array that maintains strong references to its elements.

+ pointerArrayWithStrongObjects

Returns a new pointer array that maintains strong references to its elements.

Deprecated
+ weakObjectsPointerArray

Returns a new pointer array that maintains weak references to its elements.

+ pointerArrayWithWeakObjects

Returns a new pointer array that maintains weak references to its elements.

Deprecated

Managing the Collection

count

The number of elements in the receiver.

allObjects

All the objects in the receiver.

- pointerAtIndex:

Returns the pointer at a given index.

- addPointer:

Adds a given pointer to the receiver.

- removePointerAtIndex:

Removes the pointer at a given index.

- insertPointer:atIndex:

Inserts a pointer at a given index.

- replacePointerAtIndex:withPointer:

Replaces the pointer at a given index.

- compact

Removes NULL values from the receiver.

Getting the Pointer Functions

pointerFunctions

The functions in use by the receiver.

NSPointerFunctions

An instance of NSPointerFunctions defines callout functions appropriate for managing a pointer reference held somewhere else.

Relationships

Inherits From

See Also

Pointer Collections

NSMapTable

A collection similar to a dictionary, but with a broader range of available memory semantics.

NSHashTable

A collection similar to a set, but with broader range of available memory semantics.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software