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
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);
}