Search code examples
swiftswift3cloudkitckrecord

Saving Records to CloudKit Not Working


I have tried to simply save a CKRecord to my CloudKit database but it doesn't work. I have this line of code:

db.saveRecord(itemRecord) { (record:CKRecord?,error:NSError?) -> Void in ...

The error that displays is:

cannot convert value of type '(CKRecord?, NSError?)


Solution

  • Look at the documentation for CKDatabase. The signature of just about everything has changed in Swift 3.

    It should be:

    db.save(itemRecord) { (record: CKRecord?, error: Error?) -> Void in
        // do stuff
    }