Contents

init(nonretainedObject:)

Creates a value object containing the specified object.

Declaration

init(nonretainedObject anObject: Any?)

Parameters

  • anObject:

    The value for the new object.

Return Value

A new value object that contains anObject.

Discussion

This method is equivalent to invoking init(_:withObjCType:) in this manner:

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

This method is useful if you want to add an object to a Collection but don’t want the collection to create a strong reference to it.

See Also

Working with Pointer and Object Values