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 synchronized Realm, the server only
synchronizes objects to the client when they 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:]
. Existing subscriptions for a Realm can be
looked up with -[RLMRealm subscriptions]
or -[RLMRealm subscriptionWithName:]
.
-
The unique name for this subscription.
This will be
nil
if this object was created with-[RLMResults subscribe]
. Subscription objects read from a Realm with-[RLMRealm subscriptions]
will always have a non-nil
name and subscriptions which were not explicitly named will have an automatically generated one.Declaration
Objective-C
@property (readonly, nonatomic, nullable) NSString *name;
Swift
var name: String? { get }
-
The current state of the subscription. See
RLMSyncSubscriptionState
.Declaration
Objective-C
@property (readonly, nonatomic) RLMSyncSubscriptionState state;
Swift
var state: RLMSyncSubscriptionState { get }
-
The error which occurred when registering this subscription, if any.
Will be non-nil only when
state
isRLMSyncSubscriptionStateError
.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.
Unsubscribing is an asynchronous operation and will not immediately remove the subscription from the Realm’s list of subscriptions. Observe the state property to be notified of when the subscription has actually been removed.
Declaration
Objective-C
- (void)unsubscribe;
Swift
func unsubscribe()
-
-[RLMSyncSubscription init]
is not available becauseRLMSyncSubscription
cannot be created directly.Declaration
Objective-C
- (nonnull instancetype)init;
-
+[RLMSyncSubscription new]
is not available becauseRLMSyncSubscription
cannot be created directly.Declaration
Objective-C
+ (nonnull instancetype) new;