Up

NSPointerArray class documentation

Authors

Richard Frith-Macdonald (rfm@gnu.org)

Copyright: (C) 2009 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSPointerArray class
  2. Software documentation for the NSPointerArray(NSArrayConveniences) category

Software documentation for the NSPointerArray class

NSPointerArray : NSObject

Declared in:
Foundation/NSPointerArray.h
Conforms to:
NSCopying
NSCoding
Availability: MacOS-X 10.5.0

An NSPointerArray acts like a standard mutable array except that it can contain nil and even non-object values.
The count can also be set causing the array to shrink (discarding items) or grow (adding nil/zero items).
Method summary

pointerArrayWithOptions: 

+ (id) pointerArrayWithOptions: (NSPointerFunctionsOptions)options;
Availability: MacOS-X 10.5.0

Allocate an instance, initialise using initWithOptions: and return it autoreleased.

pointerArrayWithPointerFunctions: 

+ (id) pointerArrayWithPointerFunctions: (NSPointerFunctions*)functions;
Availability: MacOS-X 10.5.0

Allocate an instance, initialise using initWithPointerFunctions: and return it autoreleased.

strongObjectsPointerArray 

+ (id) strongObjectsPointerArray;
Availability: MacOS-X 10.5.0

Returns a new pointer array for storing strong (retained) references to objects.

weakObjectsPointerArray 

+ (id) weakObjectsPointerArray;
Availability: MacOS-X 10.5.0

Returns a new pointer array for storing zeroing weak references to objects.

addPointer: 

- (void) addPointer: (void*)pointer;
Availability: MacOS-X 10.5.0

Adds an item at the end of the array.

compact 

- (void) compact;
Availability: MacOS-X 10.5.0

Removes all nil/zero items from the array.

count 

- (NSUInteger) count;
Availability: MacOS-X 10.5.0

Returns the number of items in the array.

initWithOptions: 

- (id) initWithOptions: (NSPointerFunctionsOptions)options;
Availability: MacOS-X 10.5.0

Initialises the receiver with the specified options.

initWithPointerFunctions: 

- (id) initWithPointerFunctions: (NSPointerFunctions*)functions;
Availability: MacOS-X 10.5.0

Initialises the receiver using the supplied object.

insertPointer: atIndex: 

- (void) insertPointer: (void*)pointer atIndex: (NSUInteger)index;
Availability: MacOS-X 10.5.0

Inserts an item at the specified index causing all higher indexed items to be adjusted upwards.
WARNING... the Apple documented (and implemented in MacOS-X 10.5) behavior is to raise an exception if index is the same as the count of items in the array. This is insane... for arrays, data and strings you can insert at the end of an object to append to it, so the behavior of this class in MacOS is inconsistent and must be considered buggy.

pointerAtIndex: 

- (void*) pointerAtIndex: (NSUInteger)index;
Availability: MacOS-X 10.5.0

Returns the item at the given index or raises an exception if index is out of range.

pointerFunctions 

- (NSPointerFunctions*) pointerFunctions;
Availability: MacOS-X 10.5.0

Returns an autorelease NSPointerFunctions instance giving the functions in use by the receiver.

removePointerAtIndex: 

- (void) removePointerAtIndex: (NSUInteger)index;
Availability: MacOS-X 10.5.0

Removes the item at the specified index, adjusting the positions of all higher indexed items.

replacePointerAtIndex: withPointer: 

- (void) replacePointerAtIndex: (NSUInteger)index withPointer: (void*)item;
Availability: MacOS-X 10.5.0

Description forthcoming.

setCount: 

- (void) setCount: (NSUInteger)count;
Availability: MacOS-X 10.5.0

Sets the number of items in the receiver. Adds nil/zero items to pad the end of the array, or removes extraneous items from the end.

Software documentation for the NSPointerArray(NSArrayConveniences) category

NSPointerArray(NSArrayConveniences)

Declared in:
Foundation/NSPointerArray.h
Availability: MacOS-X 10.5.0

Description forthcoming.
Method summary

pointerArrayWithStrongObjects 

+ (id) pointerArrayWithStrongObjects;
Availability: MacOS-X 10.5.0

Creates an instance configured to hold objects and prevent them from being garbage collected.

pointerArrayWithWeakObjects 

+ (id) pointerArrayWithWeakObjects;
Availability: MacOS-X 10.5.0

Creates an instance configured to hold objects, allowing them to be garbage collected and replaced by nil if/when they are collected.

allObjects 

- (NSArray*) allObjects;
Availability: MacOS-X 10.5.0

Returns an array containing all the non-nil objects from the receiver.


Up