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

# init(nonretainedObject:)

Creates a value object containing the specified object.

## Declaration

```swift
init(nonretainedObject anObject: Any?)
```

## Parameters

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

## Return Value

Return Value A new value object that contains anObject.

## Discussion

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

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