Skip to content

Instantly share code, notes, and snippets.

@jazzedge
Last active November 29, 2017 20:28
Show Gist options
  • Select an option

  • Save jazzedge/e2f124cd21e96732ba2b7d2e228dbfa6 to your computer and use it in GitHub Desktop.

Select an option

Save jazzedge/e2f124cd21e96732ba2b7d2e228dbfa6 to your computer and use it in GitHub Desktop.
Each record is represented by a CKRecord object. Once you have created a new record you can simply call saveRecord:completionHandler: on your CKDatabase object. CloudKit will connect to the Internet asynchronously when saveRecord method is invoked. If you are saving a previously retrieved entry, any changes will update the version stored on Clou…
01. Example of saving a single record
let privateDB = CKContainer.defaultContainer().privateCloudDatabase
let record = CKRecord(recordType: “Employee”)
record.setObject(“John”, forKey: “name”)
record.setObject(“Stephens Green West, Dublin 2, Dublin”, forKey: “address”)
privateDB.saveRecord(record) { savedRecord, error in
// handle errors here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment