---
title: NSPointerArray
framework: foundation
role: symbol
role_heading: Class
path: foundation/nspointerarray
---

# NSPointerArray

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

## Declaration

```swift
class NSPointerArray
```

## Overview

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 NSPointerFunctions.Options. 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

- [init(options:)](foundation/nspointerarray/init(options:).md)
- [init(pointerFunctions:)](foundation/nspointerarray/init(pointerfunctions:).md)
- [strongObjects()](foundation/nspointerarray/strongobjects().md)
- [weakObjects()](foundation/nspointerarray/weakobjects().md)

### Managing the Collection

- [count](foundation/nspointerarray/count.md)
- [allObjects](foundation/nspointerarray/allobjects.md)
- [pointer(at:)](foundation/nspointerarray/pointer(at:).md)
- [addPointer(_:)](foundation/nspointerarray/addpointer(_:).md)
- [removePointer(at:)](foundation/nspointerarray/removepointer(at:).md)
- [insertPointer(_:at:)](foundation/nspointerarray/insertpointer(_:at:).md)
- [replacePointer(at:withPointer:)](foundation/nspointerarray/replacepointer(at:withpointer:).md)
- [compact()](foundation/nspointerarray/compact().md)

### Getting the Pointer Functions

- [pointerFunctions](foundation/nspointerarray/pointerfunctions.md)
- [NSPointerFunctions](foundation/nspointerfunctions.md)

### Initializers

- [init(coder:)](foundation/nspointerarray/init(coder:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSFastEnumeration](foundation/nsfastenumeration.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)

## See Also

### Pointer Collections

- [NSMapTable](foundation/nsmaptable.md)
- [NSHashTable](foundation/nshashtable.md)
