gpt4 book ai didi

ios - 使用 NSPredicate 查询 CloudKit 的 Date 为空(或 null 或其他)

转载 作者:行者123 更新时间:2023-12-02 12:12:45 31 4
gpt4 key购买 nike

我想在 CloudKit 中查询所有具有空白日期 (0/00/0000 00:00:00) 的记录,但我不知道如何创建一个谓词来执行此操作。

这是我尝试过的方法以及相关的错误:

    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

最佳答案

我相信您的问题类似于 this one .

而不是 "ready == %@" ,您应该尝试使用 "(ready >= %@) AND (ready <= %@)"有两个引用值可供比较。

关于ios - 使用 NSPredicate 查询 CloudKit 的 Date 为空(或 null 或其他),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44272655/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com