RLMObjectId

@interface RLMObjectId : NSObject

A 12-byte (probably) unique object identifier.

ObjectIds are similar to a GUID or a UUID, and can be used to uniquely identify objects without a centralized ID generator. An ObjectID consists of:

  1. A 4 byte timestamp measuring the creation time of the ObjectId in seconds since the Unix epoch.
  2. A 5 byte random value
  3. A 3 byte counter, initialized to a random value.

ObjectIds are intended to be fast to generate. Sorting by an ObjectId field will typically result in the objects being sorted in creation order.

  • Creates a new randomly-initialized ObjectId.

    Declaration

    Objective-C

    + (nonnull instancetype)objectId;
  • Creates a new zero-initialized ObjectId.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Creates a new ObjectId from the given 24-byte hexadecimal string.

    Returns nil and sets error if the string is not 24 characters long or contains any characters other than 0-9a-fA-F.

    Declaration

    Objective-C

    - (nullable instancetype)initWithString:(nonnull NSString *)string
                                      error:(NSError *_Nullable *_Nullable)error;

    Parameters

    string

    The string to parse.

  • Creates a new ObjectId using the given date, machine identifier, process identifier.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithTimestamp:(nonnull NSDate *)timestamp
                            machineIdentifier:(int)machineIdentifier
                            processIdentifier:(int)processIdentifier;

    Parameters

    timestamp

    A timestamp as NSDate.

    machineIdentifier

    The machine identifier.

    processIdentifier

    The process identifier.

  • Comparision operator to check if the right hand side is greater than the current value.

    Declaration

    Objective-C

    - (BOOL)isGreaterThan:(nullable RLMObjectId *)objectId;
  • Comparision operator to check if the right hand side is greater than or equal to the current value.

    Declaration

    Objective-C

    - (BOOL)isGreaterThanOrEqualTo:(nullable RLMObjectId *)objectId;
  • Comparision operator to check if the right hand side is less than the current value.

    Declaration

    Objective-C

    - (BOOL)isLessThan:(nullable RLMObjectId *)objectId;
  • Comparision operator to check if the right hand side is less than or equal to the current value.

    Declaration

    Objective-C

    - (BOOL)isLessThanOrEqualTo:(nullable RLMObjectId *)objectId;
  • Get the ObjectId as a 24-character hexadecimal string.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSString *_Nonnull stringValue;
  • Get the timestamp for the RLMObjectId

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSDate *_Nonnull timestamp;