Type Method

valueWithPointer:

Creates a value object containing the specified pointer.

Declaration

+ (NSValue *)valueWithPointer:(const void *)pointer;

Parameters

aPointer

The value for the new object.

Return Value

A new value object that contains aPointer.

Discussion

This method is equivalent to invoking value: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

+ valueWithNonretainedObject:

Creates a value object containing the specified object.

pointerValue

Returns the value as an untyped pointer.

nonretainedObjectValue

The value as a non-retained pointer to an object.