Get the string used by localizedStandardCompare when it compared

I am sorting an array using localizedStandardCompare:, which gives me objects sorted in the correct localized order. Now I want to use them in indexfor a UITableView, which means that I need to generate section headers. Because they localizedStandardCompare:localize them, the line starting with "Æ" is sorted with objects A.

So, if I repeat the array and create a section for every first letter, I get the sections "A", "Æ", "A", "B", etc. Is there a way to get the string used to compare, or at least imitate it? I tried to convert with different encodings, but no one will return me "A" for "Æ".

Any other suggestions on how to create section headers for localized strings?

+5
source share
1 answer

You can use the method CFStringTransformto get the string to use.

For example, use a value kCFStringTransformToLatinto get a simple Latin string from an input string.

This will not behave exactly like a method localizedStandardCompare:, but you can use string conversion to create an additional attribute for the object that you use for the actual sort.

There are many good resources in this thread:

0
source

All Articles