我在Swift 4中做CKQuery
这样的事情:
CKQuery(recordType: package.recordType, predicate:
NSPredicate(format: "NOT (recordName IN %@)", package.recordNames as CVarArg))
...我得到了这个CKError
:
CKError(_nsError:CKError 0x60000024dce0:" Server Rejected Request"(15/2000); server message =" Unknown field' recordName'&#34 ;; uuid = BCD7C8DA-04B0-4422-8A24-F6479D234706;容器ID =" ...")
查询recordName
时是否有特殊密钥?
答案 0 :(得分:0)
在挖掘了更多内容之后,我发现您无法直接通过recordName
进行查询,但您可以通过recordID
进行查询。因此,不必比较字符串数组,而是必须构建一个CKRecordID
的数组并进行如下查询:
//- 1 - Build an array of CKRecordIDs
package.recordIDs = [CKRecordID(recordName: "..."), CKRecordID(recordName: "...")]
//- 2 - Set the predicate to use the `recordID` key
let pred = NSPredicate(format: "NOT (recordID IN %@)", package.recordIDs as CVarArg)
//- 3 - Set the query and drop your mic
CKQuery(recordType: package.recordType, predicate: pred)
我希望能帮到别人。