MVC下的 自定义CELL 的使用


1.创建model 类 nsobjct的


这些是 你接口的 所有 键 

#import <Foundation/Foundation.h>


@interface ApplyVipModel1 : NSObject


@property (nonatomic, strong) NSString *CurrentPage;

@property (nonatomic, strong) NSString *TotalPages;

@property (nonatomic, strong) NSString *TotalItems;

@property (nonatomic, strong) NSString *ItemsPerPage;

@property (nonatomic, strong) NSMutableArray *Items;

@property (nonatomic, strong) NSString *Context;


@property (nonatomic, strong) NSMutableArray *data;


@end



.m里的两个方法

#import "ApplyVipModel1.h"


@implementation ApplyVipModel1


- (void)setValue:(id)value forUndefinedKey:(NSString *)key {

    

}



- (id)valueForUndefinedKey:(NSString *)key {

    

    return nil;

}

@end




然后到tableview所在的页面 引用头



 AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];

    

    NSDictionary *postDic = @{ @"Token" : self.Token,

                               @"Owner" : self.Owner,

                               @"StoreId" : self.StoreId,

                               @"CurrentPage" : @"1",

                               @"PageSize" : @"10"};

    

    

    [manger POST:NewVipApplyListPageurl parameters:postDic success:^(NSURLSessionDataTask *task, id responseObject) {

        

        

       // NSLog(@"%@", responseObject);

        //初始化model

        ApplyVipModel1 *model1 = [[ApplyVipModel1 alloc] init];


        self.array = [NSMutableArray array];

     

        [model1 setValuesForKeysWithDictionary:responseObject ];

        

        NSMutableArray *tempArr = [NSMutableArray arrayWithArray:model1.Items];

        

        for (NSDictionary *dic in tempArr) {

       

            ApplyvipModel2 *model2 = [[ApplyvipModel2 alloc] init];

        

            [model2 setValuesForKeysWithDictionary:dic];

            

            [self.array addObject:model2];

            

            

        }

        

        

        [self.tableView reloadData];

        

    } failure:^(NSURLSessionDataTask *task, NSError *error) {

        

        

        

    }];

    


}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    

    ApplyForVipTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BCZreuse"];

    

    if (cell == nil) {

        

        cell = [[ApplyForVipTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"BCZreuse"];

        

    }


    cell.model = self.array[indexPath.row];


    return cell;

    

    

}




自定义cell里的方法

- (void)setModel:(ApplyvipModel2 *)model {

    

    if (_model != model) {

        _model = model;

    }

    

    NSLog(@"❀ == %@", model.StoreId);

    

    

}





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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值