M:模型
例子:
//用户名
@property(nonatomic,copy) NSString * username;
//头像
@property(nonatomic ,copy) NSString * imagePath;
//时间
@property(nonatomic,copy) NSString *time;
//内容
@property(nonatomic,copy) NSString * content;
//图片数组
@property(nonatomic,copy) NSArray *pictureArray;
字典转模型
- (instancetype)initWithJSONDictionary:(NSDictionary *)dict;
#import "Itemmodel.h"
@implementation Itemmodel
- (instancetype)initWithJSONDictionary:(NSDictionary *)dict {
self = [super init];
if (self) {
[self setValuesForKeysWithDictionary:dict];
}
return self;
}
//C:控制器(转模型)
for (NSDictionary *dict in array) {
QueryModel *model=[[QueryModel alloc]initWithJSONDictionary:dict];
[allData addObject:model];
}
[self.orderTableView reloadData];
{//v:视图
-(void)setModel:(QueryModel *)model{
_model=model;
[self.UserHeaderImageView setImageWithURL:[NSURL URLWithString:model.logo] placeholderImage:[UIImage imageNamed:nil]];
self.UserNameLabel.text=[NSString stringWithFormat:@"%@",model.name];
self.OrderTypeLabel.text=[NSString stringWithFormat:@"%@",model.type];
self.OrderTimeLabel.text=[NSString stringWithFormat:@"%@",model.riding_time];
self.OrderMoneyLabel.text=[NSString stringWithFormat:@"%@元",model.order_money];
self.OrderStateLabel.text=[NSString stringWithFormat:@"%@",model.oredr_type];
}