0

I am using CloudKit and have a Model class with a method which saves user preferences to the cloud database. I have successfully updated my Swift 3 syntax to account for the latest proposals released with Xcode 8 beta 6. However, I have one last error left which I can't seem to resolve. The code for my function is:

func savePreferences(preferences: UserPreferences, completion:
       @escaping (CKRecord?, NSError?) -> Void) {
    privateDatabase.save(preferences.record) {
        record, error in
        completion(record, error)
    }
}

The signature for the record property of the UserPreferencesinstance used here is:

var record : CKRecord

privateDatabase is a CKDatabase.

The error I receive is:

Cannot invoke 'save' with an argument list of type (CKRecord, (CKRecord?, Error?) -> Void)

I have found that removing the call to completion causes the error to disappear and allows a successful build.

I'm hoping someone can tell me where I am going wrong or if this is a bug with Xcode 8 beta 6.

Lew
  • 1,248
  • 8
  • 13
  • 1
    You probably need to use `Error` instead of `NSError` in your `completion` closure. – dan Aug 29 '16 at 19:05
  • Yep, embarrassing I didn't spot that! Thanks man, you should make that an answer to this question. – Lew Aug 29 '16 at 19:07

0 Answers0