我不明白为什么我的 ckquery 不获取用户创建的记录。这是我的代码:
@IBAction func browseMyComplaints(sender: AnyObject) {
// who am i?
CKContainer.defaultContainer().fetchUserRecordIDWithCompletionHandler({ userRecordID, error in
if error == nil {
println(userRecordID.description)
let query:CKQuery = CKQuery(recordType: "myComplaint", predicate: NSPredicate(format: "creatorUserRecordID = %@", userRecordID))
var results : [CKRecord] = [CKRecord]()
var operation : CKQueryOperation = CKQueryOperation(query: query)
operation.recordFetchedBlock = { (record:CKRecord!) -> Void in
results.append(record)
}
operation.queryCompletionBlock = {
(cursor:CKQueryCursor!, error:NSError!) in
if (error != nil) {
NSLog(error.description)
} else {
NSLog("no query error reported")
NSLog(String(results.count) + " found")
tvComplaintRecords = results
self.performSegueWithIdentifier("complaintList", sender: self)
}
}
publicDatabase.addOperation(operation)
} else {
println("Can not identify user due to error: \(error.localizedDescription)")
}
})
}
我的输出是:
<CKRecordID: 0x7be3f220; _46761404769b094e82053fea39b16bb5:(_defaultZone:__defaultOwner__)>
2014-10-11 12:45:32.597 ReportAMenace[15244:781048] no query error reported
2014-10-11 12:45:32.597 ReportAMenace[15244:781048] 0 found
但是有 11 条记录,包括我在运行上述查询之前创建的 1 条记录。有什么提示吗?