RLMSyncSubscriptionSet
Objective-C
@interface RLMSyncSubscriptionSet : NSObject <NSFastEnumeration>
Swift
@_nonSendable(_assumed) class RLMSyncSubscriptionSet : NSObject, NSFastEnumeration
RLMSyncSubscriptionSet
is a collection of RLMSyncSubscription
s. This is the entry point
for adding and removing RLMSyncSubscription
s.
-
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: (any Error)? { get }
-
Gets the state associated to the subscription set.
Declaration
Objective-C
@property (nonatomic, readonly) RLMSyncSubscriptionState state;
Swift
var state: RLMSyncSubscriptionState { get }
-
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. The
onComplete
block is executed after waiting for associated data to be downloaded from the server.Declaration
Objective-C
- (void)update:(nonnull void (^)(void))block onComplete:(nullable void (^)(NSError *_Nullable))onComplete;
Swift
@_unsafeInheritExecutor func update(_ block: () -> Void) async throws
Parameters
block
The block containing actions to perform to the subscription set.
onComplete
A block which is called upon synchronization of data from the server. The block will be passed
nil
if the update succeeded, and an error describing the problem otherwise. -
Synchronously performs any transactions (add/remove/update) to the subscription set within the block. The
onComplete
block is executed after waiting for associated data to be downloaded from the server.Declaration
Objective-C
- (void)update:(nonnull void (^)(void))block queue:(nullable dispatch_queue_t)queue onComplete:(nonnull void (^)(NSError *_Nonnull))onComplete;
Swift
@_unsafeInheritExecutor func update(_ block: () -> Void, queue: dispatch_queue_t?, onComplete: @escaping (any Error) -> Void)
Parameters
block
The block containing actions to perform to the subscription set.
queue
The serial queue to deliver notifications to.
onComplete
A block which is called upon synchronization of data from the server. The block will be passed
nil
if the update succeeded, and an error describing the problem otherwise.
-
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..
-
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.
-
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.
-
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 subscriptions without a name 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)removeAllUnnamedSubscriptions;
Swift
func removeAllUnnamedSubscriptions()
-
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.
-
Returns the subscription at the given
index
.Declaration
Objective-C
- (nullable RLMSyncSubscription *)objectAtIndex:(NSUInteger)index;
Swift
func object(at index: UInt) -> RLMSyncSubscription?
Parameters
index
The index.
Return Value
A subscription for the given index in the subscription set.
-
Returns the first object in the subscription set list, or
nil
if the subscriptions are empty.Declaration
Objective-C
- (nullable RLMSyncSubscription *)firstObject;
Swift
func firstObject() -> RLMSyncSubscription?
Return Value
A subscription.
-
Returns the last object in the subscription set, or
nil
if the subscriptions are empty.Declaration
Objective-C
- (nullable RLMSyncSubscription *)lastObject;
Swift
func lastObject() -> RLMSyncSubscription?
Return Value
A subscription.
-
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.