0
点赞
收藏
分享

微信扫一扫

iOS数组模型根据模型中的属性排序

千行 2021-09-29 阅读 45
iOS OC开发
@interface testModel : NSObject
//排序用的 scortId
@property (nonatomic, assign) NSInteger scortId;
@end
self.dataArray = [testModel mj_objectArrayWithKeyValuesArray:response[@"data"]];
// 排序key, 某个对象的属性名称,是否升序, YES-升序, NO-降序
NSSortDescriptor *tempDes = [NSSortDescriptor sortDescriptorWithKey:@"state" ascending:YES];
// 排序结果
self.tempArr = [self.dataArray sortedArrayUsingDescriptors:@[tempDes]];
举报

相关推荐

0 条评论