iOS: NSSortDescriptor 集合排序
2015-08-23 11:38
417 查看
NSSortDescriptor是专门用来排序的描述符。可以用来排序NSSet,NSDictionary,NSArray.
主要方法:
1. - (instancetype _Nonnull)initWithKey:(NSString * _Nullable)
key:按照排序的key。
ascending:升序或降序排列,yes为升序,no为降序。
2. - (instancetype _Nonnull)initWithKey:(NSString * _Nullable)
selector:默认情况下,这是一个简单的相等性检查,但它的行为可以通过传递一个选择器(SEL)或者比较器(NSComparator)而发生改变。任何时候当你在为面向用户的字符串排序时,一定要加入localizedStandardCompare:选择器,它将根据当前语言环境的语言规则进行排序(语言环境可能会根据大小写,变音符号等等的顺序而发生改变)。
3.+ (instancetype _Nonnull)sortDescriptorWithKey:(NSString * _Nullable)
block方法
参考资料:
https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/
http://blog.csdn.net/watsy/article/details/17754467
主要方法:
1. - (instancetype _Nonnull)initWithKey:(NSString * _Nullable)
keyPathascending:(BOOL)
ascending
key:按照排序的key。
ascending:升序或降序排列,yes为升序,no为降序。
2. - (instancetype _Nonnull)initWithKey:(NSString * _Nullable)
keyPathascending:(BOOL)
ascendingselector:(SEL _Nullable)
selector
selector:默认情况下,这是一个简单的相等性检查,但它的行为可以通过传递一个选择器(SEL)或者比较器(NSComparator)而发生改变。任何时候当你在为面向用户的字符串排序时,一定要加入localizedStandardCompare:选择器,它将根据当前语言环境的语言规则进行排序(语言环境可能会根据大小写,变音符号等等的顺序而发生改变)。
3.+ (instancetype _Nonnull)sortDescriptorWithKey:(NSString * _Nullable)
keyascending:(BOOL)
ascendingcomparator:(NSComparator _Nonnull)
cmptr
block方法
参考资料:
https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSSortDescriptor_Class/
http://blog.csdn.net/watsy/article/details/17754467
相关文章推荐
- iOS Crash
- iOS开发-VFL初窥
- iOS原生条形码扫描
- Cisco IOS服务器负载均衡
- iOS发展 - 使用您自己的自定义字体
- 暑期留校之iOS学习笔记
- iOS 开发笔记-plist使用
- 暑期留校之iOS学习笔记
- 暑期留校之iOS学习笔记
- 暑期留校iOS学习笔记
- 暑期留校iOS学习笔记
- 暑期留校iOS学习笔记
- iOS学习(2)
- addChildViewController的用法
- ios8 autoLayout
- iOS 使用腾讯地图SDK,搜索附近位置
- iOS中点击状态栏让滑动视图回到顶部
- [IOS]CoreAnimation动画效果示例
- ios中字符串的一些常见操作
- #include<iostream>和#include<iostream.h>的区别