Type Definitions
The following type definitions are available globally.
-
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 callback block for
RLMObject
notifications.If the object is deleted from the managing Realm, the block is called with
deleted
set toYES
and the other two arguments arenil
. The block will never be called again after this.If the object is modified, the block will be called with
deleted
set toNO
, anil
error, and an array ofRLMPropertyChange
objects which indicate which properties of the objects were modified.error
is alwaysnil
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]?, (any 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
Parameters
oldObject
The object from the original Realm (read-only).
newObject
The object from the migrated Realm (read-write).
-
A callback block for opening Realms asynchronously.
Returns the Realm if the open was successful, or an error otherwise.
-
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 type used for APIs which asynchronously return a
Results
.Declaration
Objective-C
typedef void (^RLMResultsCompletionBlock)(RLMResults *_Nullable, NSError *_Nullable)
Swift
typealias RLMResultsCompletionBlock = (RLMResults<AnyObject>?, (any Error)?) -> Void