---
title: "init(pointer:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsvalue/init(pointer:)"
---

# init(pointer:)

Creates a value object containing the specified pointer.

## Declaration

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

## Parameters

- `pointer`: The value for the new object.

## Return Value

Return Value A new value object that contains aPointer.

## Discussion

Discussion This method is equivalent to invoking init(_:withObjCType:) in this manner: 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 object exists. NSData objects may be more suited for arbitrary pointers than NSValue objects.

## See Also

### Working with Pointer and Object Values

- [init(nonretainedObject:)](foundation/nsvalue/init(nonretainedobject:).md)
- [pointerValue](foundation/nsvalue/pointervalue.md)
- [nonretainedObjectValue](foundation/nsvalue/nonretainedobjectvalue.md)
