RLMSyncSubscriptionSet

Objective-C

@interface RLMSyncSubscriptionSet : NSObject <NSFastEnumeration>

迅速

@_nonSendable(_assumed) class RLMSyncSubscriptionSet : NSObject, NSFastEnumeration

RLMSyncSubscriptionSetRLMSyncSubscription的集合。 这是添加和删除RLMSyncSubscription的入口点。

批量更新订阅

  • 对区块内的订阅collection同步执行任何事务(添加/删除/更新),这不会等待服务器确认并查看与此订阅collection关联的所有数据,并将在提交订阅事务后返回。

    声明

    Objective-C

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

    迅速

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

    参数

    block

    该区块包含要对订阅集执行的操作。

  • 对区块内的订阅集同步执行任何事务(添加/删除/更新)。 onComplete区块在等待从服务器下载关联数据后执行。

    声明

    Objective-C

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

    迅速

    @_unsafeInheritExecutor func update(_ block: () -> Void) async throws

    参数

    block

    该区块包含要对订阅集执行的操作。

    onComplete

    在同步来自服务器的数据时调用的区块。如果更新成功,则向区块传递nil ,否则向区块传递描述问题的错误。

  • 对区块内的订阅集同步执行任何事务(添加/删除/更新)。 onComplete区块在等待从服务器下载关联数据后执行。

    声明

    Objective-C

    - (void)update:(nonnull void (^)(void))block
             queue:(nullable dispatch_queue_t)queue
        onComplete:(nonnull void (^)(NSError *_Nonnull))onComplete;

    迅速

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

    参数

    block

    该区块包含要对订阅集执行的操作。

    queue

    要向其传递通知的串行队列。

    onComplete

    在同步来自服务器的数据时调用的区块。如果更新成功,则向区块传递nil ,否则向区块传递描述问题的错误。

查找订阅

  • 按指定名称查找订阅。

    声明

    Objective-C

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

    迅速

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

    参数

    name

    用于标识订阅的名称。

    返回值

    给定名称的订阅。

  • 通过查询查找指定对象类名称的订阅。

    声明

    Objective-C

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicateFormat

    谓词格式字符串,可以选择后跟可变数量的参数。

    返回值

    给定查询的订阅。

  • 通过查询查找指定对象类名称的订阅。

    声明

    Objective-C

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

    迅速

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicate

    用于筛选服务器上对象的谓词。

    返回值

    给定查询的订阅。

添加订阅

  • 将新订阅添加到订阅集,在写入订阅区块末尾提交时,该订阅将被发送到服务器。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicateFormat

    谓词格式字符串,可以选择后跟可变数量的参数。

  • 将新订阅添加到订阅集,在写入订阅区块末尾提交时,该订阅将被发送到服务器。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    参数

    objectClassName

    要查询的模型类的类名。

    name

    用于标识订阅的名称。

    predicateFormat

    谓词格式字符串,可以选择后跟可变数量的参数。

  • 将新订阅添加到订阅集,在写入订阅区块末尾提交时,该订阅将被发送到服务器。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicate

    定义订阅查询的谓词。

  • 将新订阅添加到订阅集,在写入订阅区块末尾提交时,该订阅将被发送到服务器。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

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

    参数

    objectClassName

    要查询的模型类的类名。

    name

    用于标识订阅的名称。

    predicate

    定义订阅查询的谓词。

删除订阅

  • 从订阅集中删除具有指定名称的订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

    func removeSubscription(withName name: String)

    参数

    name

    用于标识订阅的名称。

  • 从订阅集中删除对象类的具有指定查询的订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicateFormat

    谓词格式字符串,可以选择后跟可变数量的参数。

  • 从订阅集中删除对象类的具有指定查询的订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

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

    参数

    objectClassName

    要查询的模型类的类名。

    predicate

    用于识别要删除的订阅的谓词。

  • 从订阅集中删除订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

    func remove(_ subscription: RLMSyncSubscription)

    参数

    subscription

    要删除的订阅实例。

删除订阅

  • 从订阅集中删除所有订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    警告

    如果没有添加新订阅,则删除所有订阅将导致错误。 服务器应至少确认一个订阅。

    声明

    Objective-C

    - (void)removeAllSubscriptions;

    迅速

    func removeAllSubscriptions()
  • 从订阅集中删除所有没有名称的订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    警告

    如果没有添加新订阅,则删除所有订阅将导致错误。 服务器应至少确认一个订阅。

    声明

    Objective-C

    - (void)removeAllUnnamedSubscriptions;

    迅速

    func removeAllUnnamedSubscriptions()
  • 删除具有指定类名的所有订阅。

    警告

    此方法只能在写入订阅区块期间调用。

    声明

    Objective-C

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

    迅速

    func removeAllSubscriptions(withClassName className: String)

    参数

    className

    要查询的模型类的类名。

SubscriptionSet collection

下标

  • 返回给定index处的订阅。

    声明

    Objective-C

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

    迅速

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

    参数

    index

    索引。

    返回值

    对订阅集中给定索引的订阅。