本文介绍了如何查询CloudKit的recordID IN [CKRecordID]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的谓词想要排除已经下载并在[CKRecordID]中可用的一些记录。现在我可以查询1个CKRecordID [0],但不能查询[CKRecordID]数组。如何查询数组?

My predicate wants to exclude some records that are already downloaded and available in a [CKRecordID]. Now I can query 1 CKRecordID[0], but not the [CKRecordID] array. How can I query the array?

let excludeIDs: [CKRecordID]

这有效:

let pred1 = NSPredicate(format: "NOT(recordID = %@)", excludeIDs[0])

但这不是:

let pred1 = NSPredicate(format: "NOT(recordID IN %@)", excludeIDs)

错误:
loadImageCompareRecordIDsAndEndDateThatHaveNotEnded错误:无效谓词:无效谓词:数组成员必须符合CKRecordValue:(





)(CKRecordID)

ERROR:loadImageCompareRecordIDsAndEndDateThatHaveNotEnded Error: Invalid predicate: Invalid predicate: Array members must conform to 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]解决了它。

Using [CKReference] and not [CKRecordID] solved it.

这篇关于如何查询CloudKit的recordID IN [CKRecordID]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 15:31