Functions

The following functions are available globally.

Combine

  • Creates a publisher that emits the object each time the object changes.

    Precondition

    The object must be a managed object which has not been invalidated.

    Declaration

    Swift

    @available(macOS 10.15, watchOS 6.0, iOS 13.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOS 13.0, *)
    public func valuePublisher<T>(_ object: T) -> RealmPublishers.Value<T> where T : Object

    Parameters

    object

    A managed object to observe.

    Return Value

    A publisher that emits the object each time it changes.

  • Creates a publisher that emits the collection each time the collection changes.

    Precondition

    The collection must be a managed collection which has not been invalidated.

    Declaration

    Swift

    @available(macOS 10.15, watchOS 6.0, iOS 13.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOS 13.0, *)
    public func valuePublisher<T>(_ collection: T) -> RealmPublishers.Value<T> where T : RealmCollection, T : RealmSubscribable

    Parameters

    object

    A managed collection to observe.

    Return Value

    A publisher that emits the collection each time it changes.

  • Creates a publisher that emits an object changeset each time the object changes.

    Precondition

    The object must be a managed object which has not been invalidated.

    Declaration

    Swift

    @available(macOS 10.15, watchOS 6.0, iOS 13.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOS 13.0, *)
    public func changesetPublisher<T>(_ object: T) -> RealmPublishers.ObjectChangeset<T> where T : Object

    Parameters

    object

    A managed object to observe.

    Return Value

    A publisher that emits an object changeset each time the object changes.

  • Creates a publisher that emits a collection changeset each time the collection changes.

    Precondition

    The collection must be a managed collection which has not been invalidated.

    Declaration

    Swift

    @available(macOS 10.15, watchOS 6.0, iOS 13.0, iOSApplicationExtension 13.0, macOSApplicationExtension 10.15, tvOS 13.0, *)
    public func changesetPublisher<T>(_ collection: T) -> RealmPublishers.CollectionChangeset<T> where T : RealmCollection

    Parameters

    object

    A managed collection to observe.

    Return Value

    A publisher that emits a collection changeset each time the collection changes.

Equatable

  • Returns a Boolean indicating whether the errors are identical.

    Declaration

    Swift

    public func == (lhs: Error, rhs: Error) -> Bool

Pattern Matching

  • Pattern matching matching for Realm.Error, so that the instances can be used with Swift’s do { ... } catch { ... } syntax.

    Declaration

    Swift

    public func ~= (lhs: Realm.Error, rhs: Error) -> Bool
  • Returns the schema version for a Realm at a given local URL.

    Throws

    An NSError that describes the problem.

    Declaration

    Swift

    public func schemaVersionAtURL(_ fileURL: URL, encryptionKey: Data? = nil) throws -> UInt64

    Parameters

    fileURL

    Local URL to a Realm file.

    encryptionKey

    64-byte key used to encrypt the file, or nil if it is unencrypted.