Xcode 9.3 - NSPredicate Bool crash

后端 未结 3 1688
伪装坚强ぢ
伪装坚强ぢ 2021-01-24 15:52

After the Xcode 9.3 update, I\'ve noticed that if you want to have Predicate like this:

let predicate = NSPredicate(format: \"preferred = %@\", true as CVarArg)
         


        
3条回答
  •  情歌与酒
    2021-01-24 16:06

    // Solution 3 [ Apple Documentation ]

    let predicate = NSPredicate(format: "preferred == TRUE")
    

    The exception occurs because true is not an object (%@). You need the %d placeholder

    let predicate = NSPredicate(format: "preferred = %d", true)
    

提交回复
热议问题