I was going to use the following line of code:
[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES selector:@selector(caseInsensitiveCompare:)];
‘caseInsensitiveCompare’ is a method that I’m used to using on strings. But, the example shown that I was working from uses:
[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];
(the difference being the word localized). What does this word do – how is the ‘localized’ method different to the normal method?
The Apple developer documentation is not very informative as to how these two methods differ.
NSString provides both methods, caseInsensitiveCompare and localizedCaseInsensitiveCompare.
Certain locales may define different sorting criteria. If you are working with text localized for various locales, then use the localized version. Otherwise, use the standard version.