title: CloudKit CKModifyRecordsOperation Error
body: <p>I am using CKModifyRecordsOperation to batch create about 8000 records in CloudKit. However, I am getting a strange error for about 5% of the records: <code>record to insert already exists</code>. I have been unable to figure out why this occurs after thorough investigation and retesting. Notes to consider:</p>
  
  <ol>
  <li>The db is completely empty at start.</li>
  <li>I create a recordName locally for each record using the method <code>[NSUUID UUID].UUIDString</code>. During retesting I have also confirmed that there are no duplicate recordNames by creating a set of recordNames and comparing its count to the count of total records to upload.</li>
  <li>I have verified that each record is only uploaded only once by adding a counter to the the batch upload operation to compare the total record count pre-upload.</li>
  <li>All records are properly uploaded (compared counts in CloudKit to total records upload) - so unsure why the "errors" are occurring.</li>
  </ol>
  
  <p>Any ideas as to why these errors are being generated please?</p>
  
  <p>Code:</p>
  
  <pre><code>- (void)uploadInitialRecordsToCloudKit:(NSArray *)recordsToUpload {
  
      NSArray *recordsForThisBatch = recordsToUpload;
      NSArray *remainingRecords = nil;
  
      if ([recordsToUpload count] &gt; 350) recordsForThisBatch = [recordsToUpload subarrayWithRange:NSMakeRange(0, 350)];
      remainingRecords = [recordsToUpload subarrayWithRange:NSMakeRange([recordsForThisBatch count], [recordsToUpload count] -[recordsForThisBatch count])];
  
      CKModifyRecordsOperation *modifyRecordsOperation = [[CKModifyRecordsOperation alloc] initWithRecordsToSave:recordsForThisBatch recordIDsToDelete:nil];
      modifyRecordsOperation.modifyRecordsCompletionBlock = ^(NSArray&lt;CKRecord *&gt; * _Nullable savedRecords, NSArray&lt;CKRecordID *&gt; * _Nullable deletedRecordIDs, NSError * _Nullable operationError) {
  
          if (operationError) NSLog(@"Error during batch save to CK: %@\n\n%@", [operationError localizedDescription], operationError.userInfo);
          else NSLog(@"Batch upload to CK successful");
  
          if ([remainingRecords count] &gt; 0) [self uploadInitialRecordsToCloudKit:remainingRecords];
  
      };
  
      [[CKContainer defaultContainer] publicCloudDatabase] addOperation:modifyRecordsOperation];
  
  }
  </code></pre>