iphone - localizedCaseInsensitiveCompare : and caseInsensitiveCompare:? 有什么区别

标签 iphone objective-c ios cocoa-touch ipad

我打算使用以下代码行:

[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES selector:@selector(caseInsensitiveCompare:)];

'caseInsensitiveCompare' 是我习惯在字符串上使用的方法。但是,示例显示我正在使用:

[[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES selector:@selector(localizedCaseInsensitiveCompare:)];

(不同之处在于本地化这个词)。这个词有什么作用——“本地化”方法与普通方法有何不同?

关于这两种方法的区别,Apple 开发者文档并没有提供太多信息。

最佳答案

这意味着比较器在比较时使用国家字符集。
例如,波兰语有字母 Ł,在国家字符集中,它位于 L 和 M 之间。

例如,当我们有字符串时:Ltest、Łtest、Mtest、Ztest 字符串:

caseInsensitiveCompare 给出结果:Ltest、Mtest、Ztest、Łtest
localizedCaseInsensitiveCompare 给出结果:Ltest, Łtest, Mtest, Ztest

关于iphone - localizedCaseInsensitiveCompare : and caseInsensitiveCompare:? 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8776781/

相关文章:

ios - SoundCloud iOS SDK 架构

ios - 如何捕获完整的 tableView ios 屏幕截图

iphone - 带有 block 的UINavigationController动画过渡

iphone - 在 iphone 应用程序中从 UIView 创建 PDF 会出现异常

ios - UIPageViewController 和 UIButton 混合使用

iOS 褪色的白色背景上的强白色文本?

objective-c - 如何在swift中使用其他类的指针

iphone - Objective-C/Cocoa Touch 中的 HTML 字符解码

iphone - 方向键盘移动

ios - Firebase 使用 queryLimitedToLast 获取更多数据