Quote:
Originally Posted by Mr Jack
You're French, no? Are you comparing strings that contain accented characters? These may not be correctly compared unless you use localizedCaseInsensitiveCompare instead.
Otherwise, could you post your code, and the specific strings that you're having problems with?
|
Yes I'm french, but I think that doesn't come from this.
I cannot post the specific strings because they come from a csv of french towns that I parse.
The strings are composed an address (including the name of the city) : for instance 24 RUE DE LA LIBERTE LILLE and so on.
Every string is in uppercase, to avoid the accented characters case.
On the app, I want to find the objects that correspond to a search I'd type in the searchBar.
My test is the following one :
Quote:
for (POI *item in allPOIs) {
int index = 0;
if([searchBar.text isEqualToString:item.title] || [searchBar.text isEqualToString:item.subtitle]
|| [item.title hasPrefix:searchBar.text] || [item.subtitle hasPrefix:searchBar.text]
|| [item.title hasSuffix:searchBar.text] || [item.subtitle hasSuffix:searchBar.text]
|| ([item.title caseInsensitiveCompare:searchBar.text]==NSOrderedSame))
{
[searchTempPOIs addObject:item];
}
index++;
}
|
where searchTempPOIs is an array of POI.
Do you see where is my mistake ?
Thanks for your answers anyway