码迷,mamicode.com
首页 > 移动开发 > 详细

IOS数组的排序和筛选

时间:2015-07-19 19:57:17      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:

1.排序

            [self.tableItems sortUsingComparator:^NSComparisonResult(GPBTeacherBrief* obj1, GPBTeacherBrief* obj2) {
                if (obj1.distanceFromMe < obj2.distanceFromMe) {
                    return NSOrderedAscending;
                }else if(obj1.distanceFromMe == obj2.distanceFromMe){
                    return NSOrderedSame;
                }else{
                    return NSOrderedDescending;
                }
            }];

2.筛选

            NSPredicate* predicate = [NSPredicate predicateWithFormat:@"(startingPrice > 200) AND (startingPrice <= 500)"];
            [self.tableItems filterUsingPredicate:predicate];

 

IOS数组的排序和筛选

标签:

原文地址:http://www.cnblogs.com/guoxiaoqian/p/4659061.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!