NSPredicate在filterContentForSearchText方法中省略了特殊字符,如áâá [英] NSPredicate omits special characters like á â á in filterContentForSearchText method

查看:130
本文介绍了NSPredicate在filterContentForSearchText方法中省略了特殊字符,如áâá的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个带有 UISearchBar 的应用,我需要使用特殊字符过滤一些名称,例如à,è,ê等等。但是,如果我不喜欢请输入正确的字符串,并使用不显示的特殊字符。

I am developing an app with an UISearchBar and I need to filter some names with special characters like à, è, ê and so on.. but if I don't type the correct string with the special character it doesn't appear.

例如:如果我正在寻找cómodo字,如果我没有准确输入có,我找不到这个字/ strong>

Ex: If I am looking for cómodo word I can't find this word if I don't type exactly

如果没有特殊字符的类型,我怎么能得到那个字?例如只需输入 co <​​/ strong>。

How could I get that word without type that special characters? for example typing just co.

这是我的 NSPredicate

 NSPredicate *resultPredicate = [NSPredicate
                                    predicateWithFormat:@"SELF.word BEGINSWITH[c] %@",
                                    searchText];

谢谢

推荐答案

忽略diacrtical需要指定,[cd]而不是[c]。

Ignore diacrtical needs to be specified, "[cd]" instead of "[c]".

参见NSHipster: NSPredicate

See NSHipster: NSPredicate.

NSComparisonPredicate 选项:

NSDiacriticInsensitivePredicateOption :一个变音符号不敏感的谓词。您可以在字符串操作后使用[d]在谓词格式字符串中表示此选项(例如,像[d]naive这样的naïve)。

NSComparisonPredicate Options:
NSDiacriticInsensitivePredicateOption: A diacritic-insensitive predicate. You represent this option in a predicate format string using a [d] following a string operation (for example, "naïve" like[d] "naive").

这是一个常见的错误,它使我无法在巴黎找到我的地铁站。

Such a common error, it kept me from finding my Metro Station in Paris.

这篇关于NSPredicate在filterContentForSearchText方法中省略了特殊字符,如áâá的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆