我使用 cloudKit 构建了一个 iOS 应用程序。我正在尝试批量获取 cloudKit 中的数据,以获取设备和 cloudKit 之间的增量,但似乎 CKFetchRecordChangesOperation 在公共数据库中不起作用。我唯一的选择是 CKQuery 来获取我的数据吗?例如:
CKContainer *container = [CKContainer containerWithIdentifier:containerID];
CKDatabase *publicDatabase = [container publicCloudDatabase];
CKQuery *query = [[CKQuery alloc] initWithRecordType:recordType
predicate:[NSPredicate predicateWithFormat:@"TRUEPREDICATE"]];
CKQueryOperation *queryOp = [[CKQueryOperation alloc] initWithQuery:query];
queryOp.desiredKeys = @[@"record.recordID.recordName"];
queryOp.recordFetchedBlock = ^(CKRecord *record)
{
// do something...
};
queryOp.queryCompletionBlock = ^(CKQueryCursor *cursor, NSError *error)
{
// do something else...
};
queryOp.resultsLimit = CKQueryOperationMaximumResults;
[publicDatabase addOperation:queryOp];
我会非常感谢你的帮助。