厚积薄发,滴水穿石

搬家到主站了:http://www.cnblogs.com/cokecoffe/
随笔 - 45, 文章 - 8, 评论 - 12, 引用 - 0
数据加载中……

NSArray Sort

Sorting

 

    - (NSArray *)sortedArrayUsingSelector:(SEL)comparator
Parameters
comparator

A selector that identifies the method to use to compare two elements at a time. The method should returnNSOrderedAscending if the receiving array is smaller than the argument, NSOrderedDescending if the receiving array is larger than the argument, and NSOrderedSame if they are equal.

//selector定义了一个比较两个数组元素的方法,如果此方法返回NSOrderedAscending说明此元素比参数元素小,如果返回NSOrderedDescending说明接收的数组元素比参数元素大,NSOrderedSame相等。

    Example:
    一个元素为NSString的数组可以通过调用NSString类中的caseInsensitiveCompare:方法作为Selector。
    假设anArray已经存在:
 NSArray *sortedArray =
         [anArray sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];

posted on 2012-04-05 17:09 Wangkeke 阅读(1051) 评论(0)  编辑 收藏 引用 所属分类: IOS


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理