#StackBounty: #ios #swift #cloudkit Manually Throw a CKErrorPartialFailure

Bounty: 50

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))
  ...
  someRecords.append(record)
}

let operation = CKModifyRecordsOperation(recordsToSave: someRecords, recordIDsToDelete: nil)

operation.modifyRecordsCompletionBlock = { savedRecords, deletedRecords, error in
    DispatchQueue.main.async {
        if !self.handleError(error) { ... }
    }
}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.