RLMSyncSubscriptionSet

Objective-C

@interface RLMSyncSubscriptionSet : NSObject <NSFastEnumeration>

Swift

class RLMSyncSubscriptionSet : NSObject, NSFastEnumeration

RLMSyncSubscriptionSet is a collection of RLMSyncSubscriptions. This is the entry point for adding and removing RLMSyncSubscriptions.

  • The number of subscriptions in the subscription set.

    Declaration

    Objective-C

    @property (readonly) NSUInteger count;

    Swift

    var count: UInt { get }
  • Gets the error associated to the subscription set. This will be non-nil in case the current state of the subscription set is RLMSyncSubscriptionStateError.

    Declaration

    Objective-C

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

    Swift

    var error: Error? { get }
  • Gets the state associated to the subscription set.

    Declaration

    Objective-C

    @property (nonatomic, readonly) RLMSyncSubscriptionState state;

    Swift

    var state: RLMSyncSubscriptionState { get }

Batch Update subscriptions

  • Synchronously performs any transactions (add/remove/update) to the subscription set within the block, this will not wait for the server to acknowledge and see all the data associated with this collection of subscriptions, and will return after committing the subscription transactions.

    Declaration

    Objective-C

    - (void)update:(nonnull void (^)(void))block;

    Swift

    func update(_ block: () -> Void)

    Parameters

    block

    The block containing actions to perform to the subscription set.

  • Synchronously performs any transactions (add/remove/update) to the subscription set within the block, this will not wait for the server to acknowledge and see all the data associated with this collection of subscriptions, and will return after committing the subscription transactions.

    Declaration

    Objective-C

    - (void)update:(nonnull void (^)(void))block
        onComplete:(nonnull void (^)(NSError *_Nullable))onComplete;

    Swift

    func update(_ block: () -> Void, onComplete: @escaping (Error?) -> Void)

    Parameters

    block

    The block containing actions to perform to the subscription set.

    onComplete

    The block called upon synchronization of subscriptions to the server. Otherwise an Errordescribing what went wrong will be returned by the block

Find subscription

  • Finds a subscription by the specified name.

    Declaration

    Objective-C

    - (nullable RLMSyncSubscription *)subscriptionWithName:(nonnull NSString *)name;

    Swift

    func subscription(withName name: String) -> RLMSyncSubscription?

    Parameters

    name

    The name used to identify the subscription.

    Return Value

    A subscription for the given name.

  • Finds a subscription by the query for the specified object class name.

    Declaration

    Objective-C

    - (nullable RLMSyncSubscription *)
        subscriptionWithClassName:(nonnull NSString *)objectClassName
                            where:(nonnull NSString *)predicateFormat, ...;

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicateFormat

    A predicate format string, optionally followed by a variable number of arguments.

    Return Value

    A subscription for the given query..

  • Finds a subscription by the query for the specified object class name.

    Declaration

    Objective-C

    - (nullable RLMSyncSubscription *)
        subscriptionWithClassName:(nonnull NSString *)objectClassName
                        predicate:(nonnull NSPredicate *)predicate;

    Swift

    func subscription(withClassName objectClassName: String, predicate: NSPredicate) -> RLMSyncSubscription?

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicate

    The predicate used to to filter the objects on the server.

    Return Value

    A subscription for the given query..

Add a Subscription

  • Adds a new subscription to the subscription set which will be sent to the server when committed at the end of a write subscription block.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)addSubscriptionWithClassName:(nonnull NSString *)objectClassName
                                   where:(nonnull NSString *)predicateFormat, ...;

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicateFormat

    A predicate format string, optionally followed by a variable number of arguments.

  • Adds a new subscription to the subscription set which will be sent to the server when committed at the end of a write subscription block.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)addSubscriptionWithClassName:(nonnull NSString *)objectClassName
                        subscriptionName:(nonnull NSString *)name
                                   where:(nonnull NSString *)predicateFormat, ...;

    Parameters

    objectClassName

    The class name for the model class to be queried.

    name

    The name used the identify the subscription.

    predicateFormat

    A predicate format string, optionally followed by a variable number of arguments.

  • Adds a new subscription to the subscription set which will be sent to the server when committed at the end of a write subscription block.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)addSubscriptionWithClassName:(nonnull NSString *)objectClassName
                               predicate:(nonnull NSPredicate *)predicate;

    Swift

    func addSubscription(withClassName objectClassName: String, predicate: NSPredicate)

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicate

    The predicate defining the query for the subscription.

  • Adds a new subscription to the subscription set which will be sent to the server when committed at the end of a write subscription block.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)addSubscriptionWithClassName:(nonnull NSString *)objectClassName
                        subscriptionName:(nullable NSString *)name
                               predicate:(nonnull NSPredicate *)predicate;

    Swift

    func addSubscription(withClassName objectClassName: String, subscriptionName name: String?, predicate: NSPredicate)

    Parameters

    objectClassName

    The class name for the model class to be queried.

    name

    The name used to identify the subscription.

    predicate

    The predicate defining the query for the subscription.

Remove Subscription

  • Removes a subscription with the specified name from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)removeSubscriptionWithName:(nonnull NSString *)name;

    Swift

    func removeSubscription(withName name: String)

    Parameters

    name

    The name used the identify the subscription.

  • Removes a subscription with the specified query for the object class from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)removeSubscriptionWithClassName:(nonnull NSString *)objectClassName
                                      where:(nonnull NSString *)predicateFormat,
                                            ...;

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicateFormat

    A predicate format string, optionally followed by a variable number of arguments.

  • Removes a subscription with the specified query for the object class from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)removeSubscriptionWithClassName:(nonnull NSString *)objectClassName
                                  predicate:(nonnull NSPredicate *)predicate;

    Swift

    func removeSubscription(withClassName objectClassName: String, predicate: NSPredicate)

    Parameters

    objectClassName

    The class name for the model class to be queried.

    predicate

    The predicate which will be used to identify the subscription to be removed.

  • Removes the subscription from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)removeSubscription:(nonnull RLMSyncSubscription *)subscription;

    Swift

    func remove(_ subscription: RLMSyncSubscription)

    Parameters

    subscription

    An instance of the subscription to be removed.

Remove Subscriptions

  • Removes all subscription from the subscription set.

    Warning

    This method may only be called during a write subscription block.

    Warning

    Removing all subscriptions will result in an error if no new subscription is added. Server should acknowledge at least one subscription.

    Declaration

    Objective-C

    - (void)removeAllSubscriptions;

    Swift

    func removeAllSubscriptions()
  • Removes all subscription with the specified class name.

    Warning

    This method may only be called during a write subscription block.

    Declaration

    Objective-C

    - (void)removeAllSubscriptionsWithClassName:(nonnull NSString *)className;

    Swift

    func removeAllSubscriptions(withClassName className: String)

    Parameters

    className

    The class name for the model class to be queried.

SubscriptionSet Collection

Subscript

  • Returns the subscription at the given index.

    Declaration

    Objective-C

    - (nonnull id)objectAtIndexedSubscript:(NSUInteger)index;

    Swift

    subscript(index: UInt) -> Any { get }

    Parameters

    index

    The index.

    Return Value

    A subscription for the given index in the subscription set.