【问题标题】:can we sort dictionary in alphabetically in ios?我们可以在ios中按字母顺序对字典进行排序吗?
【发布时间】:2015-06-16 06:38:53
【问题描述】:

我正在使用此代码

NSArray *sortedKeysArray = 
[myDictionary keysSortedByValueUsingSelector:@selector(compare:)];

但它会导致这个错误

unrecognised selector sent to instance 0x7c371a00

如何解决?

我们将不胜感激

【问题讨论】:

标签: ios iphone xcode sorting sdk


【解决方案1】:

根据 Apple 的documentation

可以使用NSString 类中声明的caseInsensitiveCompare: 方法对NSString 对象数组进行排序。假设 anArray 存在,则可以通过这种方式创建数组的排序版本:

NSArray *sortedArray = [anArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    • 2015-09-13
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多