我正在尝试使用CloudKit上传一些记录更改.我正在使用CKModifyRecordsOperation来批量上传设备上已更改的记录.记录都在自定义区域中
由于某种原因,操作不断回来,并告诉我“”保护数据不匹配“
这是代码:
- (void)updloadLocalChangesWithCompletionBlock:(void (^)(NSError *error))completionBlock { // Initialize the data NSArray *localChanges = self.localChanges; NSArray *localDeletions = self.localDeletions; // Initialize the database and modify records operation CKDatabase *database = [CKContainer defaultContainer].privateCloudDatabase; CKModifyRecordsOperation *modifyRecordsOperation = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:localChanges recordIDsToDelete:localDeletions]; modifyRecordsOperation.savePolicy = CKRecordSaveAllKeys; NSLog(@"CLOUDKIT Changes Uploading: %d",localChanges.count); // Add the completion block modifyRecordsOperation.modifyRecordsCompletionBlock = ^(NSArray *savedRecords,NSArray *deletedRecordIDs,NSError *error) { if (error) { NSLog(@"[%@] Error pushing local data: %@",self.class,error); } [self.localChanges removeObjectsInArray:savedRecords]; [self.localDeletions removeObjectsInArray:deletedRecordIDs]; completionBlock(error); }; // Start the operation [database addOperation:modifyRecordsOperation]; }
这是它给我的错误:
[CloudKitSyncManager] Error Uploading Changes: <CKError 0x156654a0: "Partial Failure" (2/1011); "Failed to modify some records"; partial errors: { default-00001:(ZoneName:UserRecordID) = <CKError 0x1550b5a0: "Server Record Changed" (14/2037); "Error saving record <CKRecordID: 0x18080430; default-00001:(ZoneName:UserRecordID)> to server: Protection data didn't match"> }>