我需要查询recordType“Event”的CKRecords。当我调用recordFetchedBlock时,我会将这些记录添加到我的数组中。但是,recordFetchedBlock永远不会被调用。请帮忙!谢谢你:
//TODO: Query for all Event records
var database: CKDatabase = CKContainer.defaultContainer().privateCloudDatabase
let truePredicate = NSPredicate(value: true)
let eventQuery = CKQuery(recordType: "Event", predicate: truePredicate)
let queryOperation = CKQueryOperation(query: eventQuery)
queryOperation.recordFetchedBlock = { (record : CKRecord!) in
self.eventsArray.append(record)
println("recordFetchedBlock: \(self.eventsArray)")
}
queryOperation.queryCompletionBlock = { (cursor : CKQueryCursor!, error : NSError!) in
println("queryCompletionBlock: \(self.eventsArray)")
}
database.addOperation(queryOperation)
答案 0 :(得分:4)
所以我才意识到自己的错误。我不小心在私有数据库上调用了查询(而不是公共数据库)。目前正在踢自己..