我需要查询记录类型“事件”的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)
最佳答案
所以我才意识到我的错误。我无意中调用了私有数据库上的查询(而不是公共数据库)。正在踢自己……