RLMSyncSubscription

@interface RLMSyncSubscription : NSObject

RLMSyncSubscription represents a subscription to a set of objects in a synced Realm.

When Query-based sync is enabled for a synced Realm, the only objects that the server synchronizes to the client are those that match a sync subscription registered by that client. A subscription consists of of a query (represented by an RLMResults) and an optional name.

The state of the subscription can be observed using Key-Value Observing on the state property.

Subscriptions are created using -[RLMResults subscribe] or -[RLMResults subscribeWithName:].

  • The unique name for this subscription.

    This will be nil if a name was not provided when the subscription was created.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSString *name;

    Swift

    var name: String? { get }
  • The state of the subscription. See RLMSyncSubscriptionState.

    Declaration

    Objective-C

    @property (readonly, nonatomic) RLMSyncSubscriptionState state;

    Swift

    var state: RLMSyncSubscriptionState { get }
  • The error associated with this subscription, if any.

    Will be non-nil only when state is RLMSyncSubscriptionStateError.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSError *error;

    Swift

    var error: Error? { get }
  • Remove this subscription.

    Removing a subscription will delete all objects from the local Realm that were matched only by that subscription and not any remaining subscriptions. The deletion is performed by the server, and so has no immediate impact on the contents of the local Realm. If the device is currently offline, the removal will not be processed until the device returns online.

    Declaration

    Objective-C

    - (void)unsubscribe;

    Swift

    func unsubscribe()
  • -[RLMSyncSubscription init] is not available because RLMSyncSubscription cannot be created directly.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • +[RLMSyncSubscription new] is not available because RLMSyncSubscription cannot be created directly.

    Declaration

    Objective-C

    + (nonnull instancetype) new;