朝、あなたの質問に対する答えがこのコードに埋もれているのを見つけるでしょう :)
func saveLeCollection(theGlob:NSURL) {
let container = CKContainer(identifier: "iCloud.com")
let publicDB = container.publicCloudDatabase
let singleLink2LinkthemALL = CKRecordID(recordName: uniqReference)
let newRecord = CKRecord(recordType: "Collection", recordID: singleLink2LinkthemALL)
let whistleAsset = CKAsset(fileURL: theAssetURL)
newRecord["theAsset"] = whistleAsset
var localChanges:[CKRecord] = []
localChanges.append(newRecord)
let saveRecordsOperation = CKModifyRecordsOperation(recordsToSave: localChanges, recordIDsToDelete: nil)
saveRecordsOperation.savePolicy = .ChangedKeys
saveRecordsOperation.perRecordCompletionBlock = { record, error in
if error != nil {
self.showAlert(message: error!.localizedDescription)
print(error!.localizedDescription)
}
// deal with conflicts
// set completionHandler of wrapper operation if it's the case
}
saveRecordsOperation.modifyRecordsCompletionBlock = { savedRecords, deletedRecordIDs, error in
if error != nil {
self.showAlert(message: error!.localizedDescription)
print(error!.localizedDescription)
} else {
// deal with conflictsay
// set completionHandler of wrapper operation if it's the case
}
}
publicDB.addOperation(saveRecordsOperation)
}