Search code examples
iosswiftcloudkit

Cloud Kit's performQuery in Swift 2.0



Hi. I'm trying to make Cloud Kit based app. For data fetch I'm using this

privateDatabase.performQuery(query, inZoneWithID: nil) {
        results, error in
        if error != nil {
            print(error)
        } else {
            print(results)
            for item in results {
                self.workoutData.append(item as! CKRecord)
            }
        }
    }

but XCode says

'[CKRecord]?' does not have a member named 'Generator'

Can you help me please?


Solution

  • You need to unwrap the CKRecord array like so:

    if let res = results {
        for item in res! {
            //Do things with item
        }
    }