Returns a Boolean value indicating whether the given object is known to have a single strong reference.
- Xcode 7.1+
- Swift Standard Library
An instance of a class. This function does not modify
object; the use of
inoutis an implementation artifact.
object is known to have a single strong reference; otherwise,
nil, the return value is
is function is useful for implementing the copy-on-write optimization for the deep storage of value types:
is checks only for strong references to the given object—if
object has additional weak or unowned references, the result may still be
true. Because weak and unowned references cannot be the only reference to an object, passing a weak or unowned reference as
object always results in
If the instance passed as
object is being accessed by multiple threads simultaneously, this function may still return
true. Therefore, you must only call this function from mutating methods with appropriate thread synchronization. That will ensure that
is only returns
true when there is really one accessor, or when there is a race condition, which is already undefined behavior.