YYmOdel的方法

@interface ClassModel : NSObject
@property(nonatomic,strong)NSString *img;
@property(nonatomic,strong)NSString *step;
@end

@interface DataModel : NSObject
@property(nonatomic,strong)NSArray *steps;
@property(nonatomic,strong)NSString *title;
@property(nonatomic,strong)NSString *tags;
@property(nonatomic,strong)NSString *imtro;
@property(nonatomic,strong)NSString *albums;
@end

@interface Data : NSObject
@property(nonatomic,strong)NSArray *data;
@end

@interface Model : NSObject
@property(nonatomic,strong)Data *result;

.m中
+(NSDictionary *)modelContainerPropertyGenericClass {
// value should be Class or Class name.
return @{@“steps” : [ClassModel class]};
}

@end
@implementation Data
+(NSDictionary *)modelContainerPropertyGenericClass {
// value should be Class or Class name.
return @{@“data” : [DataModel class]
};

}

@end
@implementation Model

+(NSDictionary *)modelContainerPropertyGenericClass {
// value should be Class or Class name.
return @{@“result” : [Data class]};
}

AFHTTPSessionManager *manger=[AFHTTPSessionManager manager];
manger.responseSerializer=[AFJSONResponseSerializer serializer];
[manger GET:@“http://apis.juhe.cn/cook/query?key=f39f197e0fae5489277675172b4cea90&menu=西红柿&rn=10&pn=3” parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSLog(@“网络请求成功”);

    self.model=[Model yy_modelWithJSON:responseObject];
    [self.tbv reloadData];
     NSLog(@"%@",[self.model.result.data[0]albums]);
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
    NSLog(@"网络请求失败");
}];

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.model.result.data.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
self.tbv.rowHeight=100;
TableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@“cell”];
if (cell==nil) {
cell=[[TableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@“cell”];
}
DataModel *mod=[self.model.result.data objectAtIndex:indexPath.row ];
[cell setModel:mod];
return cell;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值