<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSPointerFunctions",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPointerFunctions"
  },
  "title" : "NSPointerFunctions"
}
-->

# NSPointerFunctions

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

```
class NSPointerFunctions
```

## Overview

The functions specified by an instance of `NSPointerFunctions` are separated into two clusters—those that define “personality” such as “object” or “C-string”, and those that describe memory management issues such as a memory deallocation function. There are constants for common personalities and memory manager selections (see `Memory and Personality Options`).

[`NSHashTable`](/documentation/Foundation/NSHashTable), [`NSMapTable`](/documentation/Foundation/NSMapTable), and [`NSPointerArray`](/documentation/Foundation/NSPointerArray) use an `NSPointerFunctions` object to define the acquisition and retention behavior for the pointers they manage. Note, however, that not all combinations of personality and memory management behavior are valid for these collections. The pointer collection objects copy the `NSPointerFunctions` object on input and output, so you cannot usefully subclass `NSPointerFunctions`.

### Subclassing Notes

`NSPointerFunctions` is not suitable for subclassing.

## Topics

### Creating and Initializing an NSPointerFunctions Object

[`init(options: NSPointerFunctions.Options)`](/documentation/Foundation/NSPointerFunctions/init(options:))

Returns an `NSPointerFunctions` object initialized with the given options.

[`+ (NSPointerFunctions *) pointerFunctionsWithOptions:(NSPointerFunctionsOptions) options;`](/documentation/Foundation/NSPointerFunctions/pointerFunctionsWithOptions:)

Returns a new `NSPointerFunctions` object initialized with the given options.

### Personality Functions

[`var hashFunction: ((UnsafeRawPointer, ((UnsafeRawPointer) -> Int)?) -> Int)?`](/documentation/Foundation/NSPointerFunctions/hashFunction)

The hash function.

[`var isEqualFunction: ((UnsafeRawPointer, UnsafeRawPointer, ((UnsafeRawPointer) -> Int)?) -> ObjCBool)?`](/documentation/Foundation/NSPointerFunctions/isEqualFunction)

The function used to compare pointers.

[`var sizeFunction: ((UnsafeRawPointer) -> Int)?`](/documentation/Foundation/NSPointerFunctions/sizeFunction)

The function used to determine the size of pointers.

[`var descriptionFunction: ((UnsafeRawPointer) -> String?)?`](/documentation/Foundation/NSPointerFunctions/descriptionFunction)

The function used to describe elements.

### Memory Configuration

[`var acquireFunction: ((UnsafeRawPointer, ((UnsafeRawPointer) -> Int)?, ObjCBool) -> UnsafeMutableRawPointer)?`](/documentation/Foundation/NSPointerFunctions/acquireFunction)

The function used to acquire memory.

[`var relinquishFunction: ((UnsafeRawPointer, ((UnsafeRawPointer) -> Int)?) -> Void)?`](/documentation/Foundation/NSPointerFunctions/relinquishFunction)

The function used to relinquish memory.

[`var usesStrongWriteBarrier: Bool`](/documentation/Foundation/NSPointerFunctions/usesStrongWriteBarrier)

Specifies whether, in a garbage collected environment, pointers should be assigned using a strong write barrier.

[`var usesWeakReadAndWriteBarriers: Bool`](/documentation/Foundation/NSPointerFunctions/usesWeakReadAndWriteBarriers)

Specifies whether, in a garbage collected environment, pointers should use weak read and write barriers.

### Constants

[`struct Options`](/documentation/Foundation/NSPointerFunctions/Options)

Defines the memory and personality options for an `NSPointerFunctions` object.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCopying`](/documentation/Foundation/NSCopying)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)