RLMThreadSafeReference

Objective-C


@interface RLMThreadSafeReference<__covariant Confined : id <RLMThreadConfined>>
    : NSObject

Swift

@_nonSendable(_assumed) class RLMThreadSafeReference<Confined> : NSObject, @unchecked Sendable where Confined : RLMThreadConfined

An object intended to be passed between threads containing a thread-safe reference to its thread-confined object.

To resolve a thread-safe reference on a target Realm on a different thread, pass to -[RLMRealm resolveThreadSafeReference:].

Warning

A RLMThreadSafeReference object must be resolved at most once. Failing to resolve a RLMThreadSafeReference will result in the source version of the Realm being pinned until the reference is deallocated.

Note

Prefer short-lived RLMThreadSafeReferences as the data for the version of the source Realm will be retained until all references have been resolved or deallocated.

  • Create a thread-safe reference to the thread-confined object.

    Note

    You may continue to use and access the thread-confined object after passing it to this constructor.

    Declaration

    Objective-C

    + (nonnull instancetype)referenceWithThreadConfined:
        (nonnull Confined)threadConfined;

    Swift

    convenience init(threadConfined: Confined)

    Parameters

    threadConfined

    The thread-confined object to create a thread-safe reference to.

  • Indicates if the reference can no longer be resolved because an attempt to resolve it has already occurred. References can only be resolved once.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isInvalidated) BOOL invalidated;

    Swift

    var isInvalidated: Bool { get }

Unavailable Methods

  • Unavailable

    RLMThreadSafeReference cannot be created directly

    -[RLMThreadSafeReference init] is not available because RLMThreadSafeReference cannot be created directly. RLMThreadSafeReference instances must be obtained by calling -[RLMRealm resolveThreadSafeReference:].

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Unavailable

    RLMThreadSafeReference cannot be created directly

    -[RLMThreadSafeReference new] is not available because RLMThreadSafeReference cannot be created directly. RLMThreadSafeReference instances must be obtained by calling -[RLMRealm resolveThreadSafeReference:].

    Declaration

    Objective-C

    + (nonnull instancetype)new;