gpt4 book ai didi

ios - CloudKit NSPredicate 不区分大小写

转载 作者:搜寻专家 更新时间:2023-11-01 05:38:59 24 4
gpt4 key购买 nike

我有一个云工具包查询,它使用下面的 NSPredicate 来搜索名称以用户在 UITextField 中输入的值开头的记录。我想让搜索不区分大小写,这样如果用户搜索“apple”,它将显示“Apple”和“apple”的结果。我怎样才能做到这一点?我还尝试将查询更改为 CONTAINS 而不是 BEGINSWITH 但应用程序没有返回任何结果,因为它正在查找数组中的值。是否可以查看字符串是否包含文本字段字符串?谢谢

var p = NSPredicate(format: "name BEGINSWITH %@", titleLabel.text!)

最佳答案

根据 CKQuery docs :

For fields that contain string values, you can match the beginning portion of the string using the BEGINSWITH operator as shown in Listing 4. You cannot use other string comparison operators such as CONTAINS or ENDSWITH. When using this operator, the field must contain a string value and must start with the string you specified. Matches are case sensitive. In the examples, the predicate matches records whose favoriteColors field contained the strings red, reddish, or red green duct tape.

关于ios - CloudKit NSPredicate 不区分大小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33106805/

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