问题
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.
Ex: If I am looking for cómodo word I can't find this word if I don't type exactly có
How could I get that word without type that special characters? for example typing just co.
This is my NSPredicate
:
NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"SELF.word BEGINSWITH[c] %@",
searchText];
Thank you
回答1:
Ignore diacrtical needs to be specified, "[cd]" instead of "[c]".
See NSHipster: NSPredicate.
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.
来源:https://stackoverflow.com/questions/23418282/nspredicate-omits-special-characters-like-%c3%a1-%c3%a2-%c3%a1-in-filtercontentforsearchtext-me