假设我在私有CloudKit数据库中有类型A
的记录。如何在不指定记录ID或查询谓词的情况下获取该类型的所有记录?
答案 0 :(得分:3)
CKQuery在初始化时需要一个非零谓词(see documentation),所以你必须指定一个谓词,即使它始终为真。例如:
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "TheRecordType", predicate: predicate)
let operation = CKQueryOperation(query: query)
operation.queryCompletionBlock = {cursor, error in
// done
}
CKContainer.defaultContainer().privateCloudDatabase.addOperation(operation)