Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cloudKit: CKFetchRecordChangesOperation in public database

I building a iOS app using cloudKit. I'm trying to make a batch fetch of the data in cloudKit getting the deltas between the device and cloudKit but it seems like CKFetchRecordChangesOperation doesn't work in public database. Does my only option option is CKQuery to fetch my data ? for example:

 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];

I'll really appreciate your help.

like image 292
user2924482 Avatar asked Oct 20 '22 11:10

user2924482


1 Answers

The apple documentation for CKFetchRecordChangesOperation states:

recordZoneID : The zone containing the records you want to fetch. The zone can be a custom zone. Syncing the default zone is not supported.

This means that it will not work on the public database since than only supports the default zone.

The correct way to achieve the same functionality would be by creating subscriptions for the data you need and retrieve that data using the CKFetchNotificationChangesOperation. Of course you could also just execute some CKQuery commands, but then you would probably often fetch data or execute queries that you don't need.

like image 146
Edwin Vermeer Avatar answered Oct 22 '22 03:10

Edwin Vermeer