Is it possible to save multiple objects CKRecordin one operation CloudKitusing Swift? I know how to extract multiple records at once, using things like CKFetchRecordsOperationor even regular performQuery. I just realized that I’m not sure that you can save several new records in one operation. The way I do it still seems ineffective to me. For instance:
let recordsToSave:[CKRecord]!
for newRecord in recordsToSave {
if let database = self.publicDatabase {
database.saveRecord(newRecord, completionHandler: { (record:CKRecord?, error:NSError?) in
if error != nil {
}
else {
if let savedRecord = record {
}
}
})
}
And while it works fine and dandy, it seems to me that it is extremely inefficient. I would think that it makes sense to have a specific function to call the entire array CKRecords, instead of having to call the database every time through a loop. Essentially, this is what I can hope for . I can do:
let recordsToSave:[CKRecord]!
if let database = self.publicDatabase {
database.saveRecords(recordsToSave, completionHandler: { (records:[CKRecord]?, error:NSError?) in
if error != nil {
}
else {
if let savedRecords = records {
}
}
})
}
, . , database.saveRecords ( ). - ? , , , , - .
, , .
- CKRecords , CloudKit? . !