Objective-c 挪威字母 æ ø å,NSArray SortedArrayUsingSelector:问题
但我没有找到解决我的问题的方法。
我写道:
NSArray *sorted = [unsorted sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
显示排序顺序 AZ,A 中为 Æ 和 Å,O 中为 Ø。 它应该是 AZ-Æ-Ø-Å,因为我使用了本地化。
But I did not find a solution to my problem.
I wrote:
NSArray *sorted = [unsorted sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
shows the sorted order A-Z with Æ and Å among A, Ø among O.
It is supposed to be A-Z-Æ-Ø-Å, since I used localized.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
覆盖整个应用程序的用户语言通常不被认为是强制特定操作的区域设置的好方法,因为用户的首选项应确定数据的排序方式。例如,如果您有一个语言类或一个有意使用双语言的程序,您可能会发现仅针对程序的某些元素覆盖排序顺序对用户很有用。尽管这需要更多工作,但如果您需要确保特定字符串始终按特定区域设置的顺序排序,则应使用比较的长形式:
调用获取挪威语的区域设置:
您可以通过使用以下 ,您最终会调用:
这不会为程序的其余部分设置默认语言,但它将在该特定比较中显式使用指定的区域设置。
Overriding the user's language for the entire application is generally not considered to be a good way to force the locale for a particular operation, as the user's preferences should determine how data is sorted. If, for example, you have a language class or an otherwise intentionally-dual-language program), you might find it useful to the user to override the sorting order just for certain elements of the program. Although it's a bit more work, if you need to make sure that the particular strings are always sorted in order for a particular locale, you should use the long form of the compare:
You can get the locale for Norwegian by using the call:
So, you'd end up calling:
This will not set the default language for the rest of the program, but it will explicitly use the specified locale in that particular comparison.
我通过在
-viewDidLoad
中插入这一行解决了这个问题:I solved it by inserting this line in
-viewDidLoad
: