我的谓词要排除某些已下载并在[CKRecordID]中可用的记录。现在,我可以查询1个CKRecordID [0],但不能查询[CKRecordID]数组。我如何查询数组?
let excludeIDs: [CKRecordID]
这有效:
let pred1 = NSPredicate(format: "NOT(recordID = %@)", excludeIDs[0])
但这不是:
let pred1 = NSPredicate(format: "NOT(recordID IN %@)", excludeIDs)
错误:
loadImageCompareRecordIDsAndEndDateThatHaveNotEnded错误:无效的谓词:无效的谓词:数组成员必须符合CKRecordValue:(
“”,
“”,
“”,
“”,
”
)(CKRecordID)
该代码的其他常规部分:
let sort = NSSortDescriptor(key: "creationDate", ascending: false)
let query = CKQuery(recordType: MyRecordTypes.ImageCompare, predicate: pred1)
query.sortDescriptors = [sort]
let operation = CKQueryOperation(query: query)
operation.desiredKeys = ["endDate"]
operation.resultsLimit = 50
最佳答案
使用[CKReference]而不是[CKRecordID]可以解决该问题。
关于ios - 如何在CloudKit中查询记录ID IN [CKRecordID],我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32900235/