Question

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

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top