一、 model.h
#import <Foundation/Foundation.h>
@interface NewMembersModel : NSObject
/** 申请医生id */
@property (nonatomic, assign) NSInteger doctorId;
/** 医生申请的团队id */
@property (nonatomic, assign) NSInteger teamId;
/** 申请的团队名称 */
@property (nonatomic, copy) NSString *teamName;
/** 申请id 当state==2的时候为nil */
@property (nonatomic, assign) long applyForId;
/** 医生头像 */
@property (nonatomic, copy) NSString *headImg;
/** 医生名字 */
@property (nonatomic, copy) NSString *name;
/** 当前状态 1申请中 2已同意 3已取消 4已拒绝 */
@property (nonatomic, assign) NSInteger state;
/** 操作时间 */
@property (nonatomic, copy) NSString *times;
@end
二、 下面两个排序方法均在数据请求成功后进行操作
2.1、根据单个属性升序排序
self.dataArray = [NewMembersModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
// 排序key, 某个对象的属性名称,是否升序, YES-升序, NO-降序
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"state" ascending:YES];
// 排序结果
self.tempArr = [self.dataArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
2.2、根据多个属性一个升序一个降序排序
self.dataArray = [NewMembersModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
// 排序key, 某个对象的属性名称,是否升序, YES-升序, NO-降序
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"state" ascending:YES];
NSSortDescriptor *sortDescriptor1 = [NSSortDescriptor sortDescriptorWithKey:@"doctorId" ascending:NO];
// 排序结果
self.tempArr = [self.dataArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sortDescriptor, sortDescriptor1, nil]];
网友评论