ios - 优化 CKFetchRecordZoneChangesOperation 以获取 desiredKeys

标签 ios ios10 cloudkit ckoperation ckrecordzone

在我的 CloudKit 应用程序中,我在存储所有 CKRecords 的私有(private)数据库中创建了一个区域。 CKRecords 可以是 10 种不同的记录类型,其中一些可以附加 CKAssets。我使用 CKFetchRecordZoneChangesOperation 查找此区域中的记录更改,并下载它们。我想优化 CKFetchRecordZoneChangesOperation 以便我在下载中只包含 desiredKeys ,所以我当时不下载 CKAsset,但似乎没有以任何方式指定每个记录类型。相反,您似乎只能在 CKFetchRecordZoneChangesOptions 上指定 desiredKeys,这是在 zoneID 上设置的。

那么考虑到该区域中有不同类型的记录类型,我如何在我的 CKFetchRecordZoneChangesOperation 提取上指定“desiredKeys”?我在这里错过了一些简单的东西吗? 我猜想的另一个(激进的)选项是为每种记录类型创建一个记录区域,但如果可能的话,我不想走这条路。

谢谢。

最佳答案

唯一的选择是为每种记录类型添加字段名称前缀。这使得为​​每个记录类型指定所需的键成为可能。

https://developer.apple.com/reference/cloudkit/ckfetchrecordzonechangesoptions/1640472-desiredkeys状态:

var desiredKeys: [String]?

...

Because the records you fetch can be of different types, the array should contain the merged set of all field names for the requested records and include at least one field name from each record type.

...

您的观察是正确的。您也不能获取特定于记录类型的区域更改。

关于ios - 优化 CKFetchRecordZoneChangesOperation 以获取 desiredKeys,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43746117/

相关文章:

iOS RestKit 日期解析

android - 您如何做到这一点,以便您可以使用电话号码登录应用程序?

ios - 可以将 html/css/js 嵌入到 ios native 应用程序中

ios - CloudKit - NSPredicate 用于在引用列表中查找包含多个 CKReferences 的所有记录

swift - CloudKit:多个用户同时写入同一条记录

ios - Swift 3 需要有关 Realm 查询的帮助

ios - Instagram 或 Facebook 的 feed 在 iOS 中是如何工作的

ios - Swift 3 iOS 10 引用 UIImageView 获取其他函数的值

swift - AVCaptureDevicePosition.front 不工作

ios - 更新通知的替代方法不起作用