当使用 NSPredicate
时,我试图搜索包含在数组中的所有对象(字符串)。下面的代码示例有效,但谓词仅收集第一个索引中的对象?? NSPredicate
用于CKQueryOperation
。
每个 Record
都有一个名为 Category
的键的值。
let array: [String] = ["Education", "Sport", "TV and Film"]
// select all records
//let predicate = NSPredicate(format: "Category = %@", category )
let predicate = NSPredicate (format: "Category == %@", argumentArray: array)
let query = CKQuery(recordType: "quizRecord", predicate: predicate)
// get just one value only
let operation = CKQueryOperation(query: query)
//code works but only queries Records with the Category for "Education"
尝试替换:
"Category == %@"
与:
"Category IN %@"
关于ios - 使用 NSPredicate 和数组进行 cloudKit 搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35221420/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |