使用NSPredicate
時,我試圖搜索數組中包含的所有對象(字符串)。下面的代碼示例工作,但謂詞只收集第一個索引中的對象?? NSPredicate
用於CKQueryOperation
。 每個Record
都有一個名爲Category
的密鑰的值。使用NSPredicate和數組進行cloudKit搜索
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"
http://stackoverflow.com/questions/18059170/nspredicate-predicatewithformatargumentarray-only-evaluating-first-argument? – Larme
@Larme問題/答案在ObjectiveC中 - 我嘗試了很多變體,但我可以將它翻譯成Swift。 – pete
你如何獲得多個價值? –