In Objective-C, I might use +[NSValue valueWithNonretainedObject:]
to keep a unique ID of an object, where I don't wish to retain the object itself. Seems like that's deprecated for Swift.
How to do in Swift?
It's still there. It's just been adjusted to be one of NSValue
's initializers:
let anObject = "Hello!"
let value = NSValue(nonretainedObject: anObject)