1
我想查詢CloudKit中是否有空白日期(0/00/0000 00:00:00)的所有記錄,但我不知道如何做出一個將做到的謂詞。使用NSPredicate查詢CloudKit以查找空白(或空或其他)的日期
這裏是我試過,以及相關的錯誤:
let predicate = NSPredicate(format: "ready == nil") // <ready != nil>: <nil> is not a function expression
let predicate = NSPredicate(format: "ready == NIL") // <ready == nil>: <nil> is not a function expression
let predicate = NSPredicate(format: "ready != NULL") // <ready != nil>: <nil> is not a function expression
let predicate = NSPredicate(format: "ready == %@", NSNull()) // NSNull not allowed in comparison expression
let predicate = NSPredicate(format: "ready == $NULL") // Unable to parse the format string "ready == $NULL"
let predicate = NSPredicate(format: "ready == $BLANK") // <ready == $BLANK>: <$BLANK> is not a function expression
let blankDate: Date = Date.init()
let predicate = NSPredicate(format: "ready == %@", blankDate as NSDate)
let haveADate = NSPredicate(format: "ready > %@", NSDate.distantPast as NSDate)
let predicate = NSCompoundPredicate(notPredicateWithSubpredicate: haveADate) // Inverting a valid one doesn't work either
經過更多的研究,我相信這是不可能的。根據這裏接受的答案:https://stackoverflow.com/questions/32683691/how-do-i-query-for-nil-values-with-cloudkit-js CloudKit是一個鍵值存儲,所以如果該值沒有設置,那麼密鑰甚至不存在。 – garafajon