您的位置:首页 > 移动开发 > IOS开发

iOSMVC设计模式

2015-11-26 16:26 375 查看
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];

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: