Type Definitions

The following type definitions are available globally.

Notification Constants

  • A notification indicating that changes were made to a Realm.

    Declaration

    Objective-C

    typedef NSString *RLMNotification

    Swift

    struct RLMNotification : _ObjectiveCBridgeable, Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable, @unchecked Sendable
  • A token representing an identity provider’s credentials.

    Declaration

    Objective-C

    typedef NSString *RLMCredentialsToken

    Swift

    typealias RLMCredentialsToken = NSString
  • A type representing the unique identifier of an Atlas App Services identity provider.

    Declaration

    Objective-C

    typedef NSString *RLMIdentityProvider

    Swift

    struct RLMIdentityProvider : _ObjectiveCBridgeable, Hashable, Equatable, _SwiftNewtypeWrapper, RawRepresentable, @unchecked Sendable
  • A block type used to report an error

    Declaration

    Objective-C

    typedef void (^RLMEmailPasswordAuthOptionalErrorBlock)(NSError *_Nullable)

    Swift

    typealias RLMEmailPasswordAuthOptionalErrorBlock = @Sendable (Error?) -> Void
  • A callback block for RLMObject notifications.

    If the object is deleted from the managing Realm, the block is called with deleted set to YES and the other two arguments are nil. The block will never be called again after this.

    If the object is modified, the block will be called with deleted set to NO, a nil error, and an array of RLMPropertyChange objects which indicate which properties of the objects were modified.

    error is always nil and will be removed in a future version.

    Declaration

    Objective-C

    typedef void (^RLMObjectChangeBlock)(BOOL,
                                         NSArray<RLMPropertyChange *> *_Nullable,
                                         NSError *_Nullable)

    Swift

    typealias RLMObjectChangeBlock = (Bool, [RLMPropertyChange]?, Error?) -> Void
  • A log callback function which can be set on RLMLogger.

    The log function may be called from multiple threads simultaneously, and is responsible for performing its own synchronization if any is required.

    Declaration

    Objective-C

    typedef void (^RLMLogFunction)(RLMLogLevel, NSString *_Nonnull)

    Swift

    typealias RLMLogFunction = @Sendable (LogLevel, String) -> Void
  • A block type which provides both the old and new versions of an object in the Realm. Object properties can only be accessed using keyed subscripting.

    Declaration

    Objective-C

    typedef void (^RLMObjectMigrationBlock)(RLMObject *_Nullable,
                                            RLMObject *_Nullable)

    Swift

    typealias RLMObjectMigrationBlock = (RLMObject?, RLMObject?) -> Void

    Parameters

    oldObject

    The object from the original Realm (read-only).

    newObject

    The object from the migrated Realm (read-write).

  • Block which returns an object id on a successful insert, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoInsertBlock)(id<RLMBSON> _Nullable, NSError *_Nullable)

    Swift

    typealias RLMMongoInsertBlock = @Sendable (RLMBSON?, Error?) -> Void
  • Block which returns an array of object ids on a successful insertMany, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoInsertManyBlock)(NSArray<id<RLMBSON>> *_Nullable,
                                            NSError *_Nullable)

    Swift

    typealias RLMMongoInsertManyBlock = @Sendable ([RLMBSON]?, Error?) -> Void
  • Block which returns an array of Documents on a successful find operation, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoFindBlock)(
        NSArray<NSDictionary<NSString *, id<RLMBSON>> *> *_Nullable,
        NSError *_Nullable)

    Swift

    typealias RLMMongoFindBlock = @Sendable ([[String : RLMBSON]]?, Error?) -> Void
  • Block which returns a Document on a successful findOne operation, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoFindOneBlock)(
        NSDictionary<NSString *, id<RLMBSON>> *_Nullable_result, NSError *_Nullable)

    Swift

    typealias RLMMongoFindOneBlock = @Sendable ([String : RLMBSON]?, Error?) -> Void
  • Block which returns the number of Documents in a collection on a successful count operation, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoCountBlock)(NSInteger, NSError *_Nullable)

    Swift

    typealias RLMMongoCountBlock = @Sendable (Int, Error?) -> Void
  • Block which returns an RLMUpdateResult on a successful update operation, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoUpdateBlock)(RLMUpdateResult *_Nullable,
                                        NSError *_Nullable)

    Swift

    typealias RLMMongoUpdateBlock = @Sendable (RLMUpdateResult?, Error?) -> Void
  • Block which returns the deleted Document on a successful delete operation, or an error should one occur.

    Declaration

    Objective-C

    typedef void (^RLMMongoDeleteBlock)(
        NSDictionary<NSString *, id<RLMBSON>> *_Nullable_result, NSError *_Nullable)

    Swift

    typealias RLMMongoDeleteBlock = @Sendable ([String : RLMBSON]?, Error?) -> Void
  • A block for receiving an RLMResponse from the RLMNetworkTransport.

    Declaration

    Objective-C

    typedef void (^RLMNetworkTransportCompletionBlock)(RLMResponse *_Nonnull)

    Swift

    typealias RLMNetworkTransportCompletionBlock = @Sendable (RLMResponse) -> Void
  • A callback block for opening Realms asynchronously.

    Returns the Realm if the open was successful, or an error otherwise.

    Declaration

    Objective-C

    typedef void (^RLMAsyncOpenRealmCallback)(RLMRealm *_Nullable,
                                              NSError *_Nullable)

    Swift

    typealias RLMAsyncOpenRealmCallback = (RLMRealm?, Error?) -> Void
  • The Id of the asynchronous transaction.

    Declaration

    Objective-C

    typedef unsigned int RLMAsyncTransactionId

    Swift

    typealias RLMAsyncTransactionId = UInt32
  • The type of a block to run whenever the data within the Realm is modified.

    Declaration

    Objective-C

    typedef void (^RLMNotificationBlock)(RLMNotification _Nonnull,
                                         RLMRealm *_Nonnull)

    Swift

    typealias RLMNotificationBlock = (RLMNotification, RLMRealm) -> Void
  • The type of a migration block used to migrate a Realm.

    Declaration

    Objective-C

    typedef void (^RLMMigrationBlock)(RLMMigration *_Nonnull, uint64_t)

    Swift

    typealias RLMMigrationBlock = @Sendable (RLMMigration, UInt64) -> Void

    Parameters

    migration

    A RLMMigration object used to perform the migration. The migration object allows you to enumerate and alter any existing objects which require migration.

    oldSchemaVersion

    The schema version of the Realm being migrated.

  • A block called when opening a Realm for the first time during the life of a process to determine if it should be compacted before being returned to the user. It is passed the total file size (data + free space) and the total bytes used by data in the file.

    Return YES to indicate that an attempt to compact the file should be made. The compaction will be skipped if another process is accessing it.

    Declaration

    Objective-C

    typedef BOOL (^RLMShouldCompactOnLaunchBlock)(NSUInteger, NSUInteger)

    Swift

    typealias RLMShouldCompactOnLaunchBlock = @Sendable (UInt, UInt) -> Bool
  • A block which receives a subscription set instance, that can be used to add an initial set of subscriptions which will be executed when the Realm is first opened.

    Declaration

    Objective-C

    typedef void (^RLMFlexibleSyncInitialSubscriptionsBlock)(
        RLMSyncSubscriptionSet *_Nonnull)

    Swift

    typealias RLMFlexibleSyncInitialSubscriptionsBlock = @Sendable (RLMSyncSubscriptionSet) -> Void
  • A block type used for APIs which asynchronously return a Results.

    Declaration

    Objective-C

    typedef void (^RLMResultsCompletionBlock)(RLMResults *_Nullable,
                                              NSError *_Nullable)

    Swift

    typealias RLMResultsCompletionBlock = (RLMResults<AnyObject>?, Error?) -> Void
  • A block type used to report before a client reset will occur. The beforeFrozen is a frozen copy of the local state prior to client reset.

    Declaration

    Objective-C

    typedef void (^RLMClientResetBeforeBlock)(RLMRealm *_Nonnull)

    Swift

    typealias RLMClientResetBeforeBlock = @Sendable (RLMRealm) -> Void
  • A block type used to report after a client reset occurred. The beforeFrozen argument is a frozen copy of the local state prior to client reset. The after argument contains the local database state after the client reset occurred.

    Declaration

    Objective-C

    typedef void (^RLMClientResetAfterBlock)(RLMRealm *_Nonnull, RLMRealm *_Nonnull)

    Swift

    typealias RLMClientResetAfterBlock = @Sendable (RLMRealm, RLMRealm) -> Void
  • A log callback function which can be set on RLMSyncManager.

    The log function may be called from multiple threads simultaneously, and is responsible for performing its own synchronization if any is required.

    Declaration

    Objective-C

    typedef void (^RLMSyncLogFunction)(RLMSyncLogLevel, NSString *_Nonnull)

    Swift

    typealias RLMSyncLogFunction = @Sendable (RLMSyncLogLevel, String) -> Void
  • A block type representing a block which can be used to report a sync-related error to the application. If the error pertains to a specific session, that session will also be passed into the block.

    Declaration

    Objective-C

    typedef void (^RLMSyncErrorReportingBlock)(NSError *_Nonnull,
                                               RLMSyncSession *_Nullable)

    Swift

    typealias RLMSyncErrorReportingBlock = @Sendable (Error, RLMSyncSession?) -> Void
  • The type of a progress notification block intended for reporting a session’s network activity to the user.

    transferredBytes refers to the number of bytes that have been uploaded or downloaded. transferrableBytes refers to the total number of bytes transferred, and pending transfer.

    Declaration

    Objective-C

    typedef void (^RLMProgressNotificationBlock)(NSUInteger, NSUInteger)

    Swift

    typealias RLMProgressNotificationBlock = (UInt, UInt) -> Void
  • A block type used to report an error related to a specific user.

    Declaration

    Objective-C

    typedef void (^RLMOptionalUserBlock)(RLMUser *_Nullable, NSError *_Nullable)

    Swift

    typealias RLMOptionalUserBlock = @Sendable (RLMUser?, Error?) -> Void
  • A block type used to report an error on a network request from the user.

    Declaration

    Objective-C

    typedef void (^RLMUserOptionalErrorBlock)(NSError *_Nullable)

    Swift

    typealias RLMUserOptionalErrorBlock = @Sendable (Error?) -> Void
  • A block which returns a dictionary should there be any custom data set for a user

    Declaration

    Objective-C

    typedef void (^RLMUserCustomDataBlock)(NSDictionary *_Nullable,
                                           NSError *_Nullable)

    Swift

    typealias RLMUserCustomDataBlock = @Sendable ([AnyHashable : Any]?, Error?) -> Void
  • A block type for returning from function calls.

    Declaration

    Objective-C

    typedef void (^RLMCallFunctionCompletionBlock)(id<RLMBSON> _Nullable,
                                                   NSError *_Nullable)

    Swift

    typealias RLMCallFunctionCompletionBlock = @Sendable (RLMBSON?, Error?) -> Void