OGeek|极客世界-中国程序员成长平台

标题: ios - 优化 CKFetchRecordZoneChangesOperation 以获取所需键 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:36
标题: ios - 优化 CKFetchRecordZoneChangesOperation 以获取所需键

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

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

谢谢。



Best Answer-推荐答案


唯一的选择是为每种记录类型添加字段名称的前缀。这样就可以为每种记录类型指定所需的键。

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 以获取所需键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43746117/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4