ObjectKeyIdentifiable

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public protocol ObjectKeyIdentifiable : Identifiable

A protocol which defines a default identity for Realm Objects

Declaring your Object subclass as conforming to this protocol will supply a default implementation for Identifiable‘s id which works for Realm Objects:

// Automatically conforms to `Identifiable`
class MyObjectType: Object, ObjectKeyIdentifiable {
    // ...
}

You can also manually conform to Identifiable if you wish, but note that using the object’s memory address does not work for managed objects.

  • id

    The stable identity of the entity associated with self.

    Declaration

    Swift

    var id: UInt64 { get }

Available where Self: ObjectBase

  • id Default implementation

    Default Implementation

    A stable identifier for this object. For managed Realm objects, this value will be the same for all object instances which refer to the same object (i.e. for which Object.isSameObject(as:) returns true).

    Declaration

    Swift

    public var id: UInt64 { get }