1 Reply
      Latest reply on Jul 24, 2019 9:41 PM by PBK
      gmcerveny Level 1 Level 1 (0 points)

        I'm tracking down a CloudKit error of 'Failed to modify some records.'


        How can I throw this error so that I can test my error handling code?


        Is there a property of CKRecord I can set to force it to fail?


        Code is currently something like:


        var someRecords = [CKRecord]()
        for i in (1...10) {
          let record = CKRecord(recordType: "Track", recordID: CKRecord.ID(zoneID: recordZone.zoneID))
        let operation = CKModifyRecordsOperation(recordsToSave: someRecords, recordIDsToDelete: nil)
        operation.modifyRecordsCompletionBlock = { savedRecords, deletedRecords, error in
            DispatchQueue.main.async {
                if !self.handleError(error) { ... }
        • Re: Force a CloudKit Error
          PBK Level 7 Level 7 (3,435 points)

          You can deploy to production and then try to add new fields in some records.


          You can set



          and then change that fetch that record, change it and save it and then change it again and try to save it a second time.  The second time will fail becuase the original was changed after the fetch.