<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSValue/init(pointer:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSValue(cm)valueWithPointer:"
  },
  "title" : "init(pointer:)"
}
-->

# init(pointer:)

Creates a value object containing the specified pointer.

```
init(pointer: UnsafeRawPointer?)
```

## Parameters

`pointer`

The value for the new object.

## Return Value

A new value object that contains `aPointer`.

## Discussion

This method is equivalent to invoking [`init(_:withObjCType:)`](/documentation/Foundation/NSValue/init(_:withObjCType:)) in this manner:

```objc
NSValue *theValue = [NSValue value:&aPointer withObjCType:@encode(void *)];
```

This method does not copy the contents of `aPointer`, so you must not to free the memory at the pointer destination while the [`NSValue`](/documentation/Foundation/NSValue) object exists. [`NSData`](/documentation/Foundation/NSData) objects may be more suited for arbitrary pointers than [`NSValue`](/documentation/Foundation/NSValue) objects.

---

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)