ObjectIdentifier

struct ObjectIdentifier

A unique identifier for a class instance or metatype. This can be used by reflection clients to recognize cycles in the object graph.

In Swift, only class instances and metatypes have unique identities. There is no notion of identity for structs, enums, functions, or tuples.

Inheritance Comparable, Equatable, Hashable View Protocol Hierarchy →
Import import Swift

Initializers

init(_: Any.Type)

Construct an instance that uniquely identifies the metatype x.

Declaration

init(_ x: Any.Type)
init(_: AnyObject)

Construct an instance that uniquely identifies the class instance x.

Declaration

init(_ x: AnyObject)

Instance Variables

var hashValue: Int

The hash value.

Axiom: x == y implies x.hashValue == y.hashValue.

Note: The hash value is not guaranteed to be stable across different invocations of the same program. Do not persist the hash value across program runs.

Declaration

var hashValue: Int { get }
var uintValue: UInt

Convert to a UInt that captures the full value of self.

Axiom: a.uintValue == b.uintValue iff a == b.

Declaration

var uintValue: UInt { get }