How to compare A to Á on the iPhone
I need to compare 2 strings, looking at the first letter only.
Is the开发者_运维问答re a method to compare A to Á, and recognize it as A, without the ´
?
NSString
has a diacritic-insensitive comparison mode which will do what you're after.
// should return NSOrderedSame, i.e. identical
[@"Apple" compare:@"Ápple"
options:NSDiacriticInsensitiveSearch]
If you want it to be case-insensitive as well:
// ditto
[@"APPLE" compare:@"Ápple"
options:NSDiacriticInsensitiveSearch | NSCaseInsensitiveSearch]
精彩评论