I make calls to the iCloud database in two different ways in my app:
1.
Calling a CKDatabase
convenience method works perfectly in development (simulator) and production (device) environments:
let privateDatabase = CKContainer.defaultContainer().privateCloudDatabase
privateDatabase.fetchRecordWithID(recordID, completionHandler: { (record, error) -> Void in
// handle record and errors
})
2.
Adding CKOperations
to the main queue works perfectly in the development environment, and works for a while when I test in the production environment - but then arbitrarily, after a few hours of intermittent testing, this call to the database just starts hanging - no errors are produced, and no completion code is executed. (The fetchRecordWithID
call still works perfectly all the time.)
let op1 = CKModifyRecordsOperation(recordsToSave: records, recordIDsToDelete: nil)
op1.modifyRecordsCompletionBlock = { (savedRecords, deletedRecordIDs, error) -> Void in
// handle records and errors
}
op1.database = privateDatabase
// let op2, op3...
NSOperationQueue.mainQueue().addOperations([
op1,
op2,
op3,
], waitUntilFinished: false)
In the Usage panel in the CloudKit dashboard, nothing is even remotely approaching a limit. What other variables am I not considering - or what other tests can I run to figure out what's going wrong?