Contents

init(pointer:)

Creates a value object containing the specified pointer.

Declaration

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:) 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