服务器返回的内容如下
responseObject{
message = "访问成功!!";
result = (
{
attNameList = (
{
attName = "业务申请表";
fileCount = 0;
idList = 107;
remark = "*法人承租人盖章,实际控制人签字并提供身份证复印件*自然人承租人及配偶(如已婚)签字";
},
{
attName = "管理人调查报告";
fileCount = 0;
idList = 108;
remark = "*管理方所表达的意见为同意该承租人通过*管理人盖章";
},
{
attName = "风险建议书";
fileCount = 0;
idList = 109;
remark = "*管理方所表达的意见为同意该承租人通过*管理人盖章";
}
);
idStage = 1;
nameStage = "资信调查报告";
},
{
attNameList = (
{
attName = "承租人身份证正反面复印件";
fileCount = 0;
idList = 121;
remark = "*身份证在有效期内*承租人签字按手印*单身不需要提供证明";
},
{
attName = "承租人户口本整本复印件";
fileCount = 0;
idList = 122;
remark = "*身份证在有效期内*承租人签字按手印*单身不需要提供证明";
},
{
attName = "承租人结婚证(如已婚)";
fileCount = 0;
idList = 123;
remark = "*身份证在有效期内 *承租人签字按手印 *单身不需要提供证明";
},
{
attName = "配偶身份证正反面复印件(如已婚)";
fileCount = 0;
idList = 124;
remark = "*证件在有效期 *配偶签字按手印";
},
{
attName = "扣款协议书(三联单)";
fileCount = 0;
idList = 125;
remark = "*承租人签字";
},
{
attName = "扣款卡正反面复印件";
fileCount = 0;
idList = 126;
remark = "*承租人签字";
},
{
attName = "其他(如有)";
fileCount = 0;
idList = 127;
remark = "*资产证明等";
}
);
idStage = 3;
nameStage = "自然人承租人基础资料";
},
{
attNameList = (
{
attName = "所有权确认函(如有)";
fileCount = 0;
idList = 128;
remark = "*合同编号、承租人姓名、车辆信息与实际一致 *挂靠公司加盖公章可使用复印件、原件投放后一周之内补齐";
},
{
attName = "挂靠公司(如有)营业执照复印件";
fileCount = 0;
idList = 129;
remark = "证件照在有效期内 *挂靠公司加盖公章";
},
{
attName = "挂靠公司(如有)组代证复印件";
fileCount = 0;
idList = 130;
remark = "证件照在有效期内 *挂靠公司加盖公章";
}
);
idStage = 4;
nameStage = "挂靠材料";
},
{
attNameList = (
{
attName = "经销商业务确认函";
fileCount = 0;
idList = 131;
remark = "经销商加盖公章";
},
{
attName = "融资租赁合同";
fileCount = 0;
idList = 132;
remark = "法人承租人加盖公章;自然人承租人签字按手印 *填写签订地点";
},
{
attName = "租赁要素表";
fileCount = 0;
idList = 133;
remark = "合同号、金额、价格信息、车架号与实际一致 *法人承租人加盖公章;自然人承租人签字按手印";
},
{
attName = "产品买卖合同";
fileCount = 0;
idList = 134;
remark = "合同号、车辆信息、金额等与实际一致 *法人承租人加盖公章;自然人承租人签字按手印 *经销商加盖公章";
},
{
attName = "抵押合同";
fileCount = 0;
idList = 135;
remark = "承租人盖章或挂靠公司盖公章 注:N为台数(挂车业算一台)";
},
{
attName = "业务管理服务合同";
fileCount = 0;
idList = 136;
remark = "承租人签字按手印/加盖公章";
}
);
idStage = 5;
nameStage = "法律要件";
}
);
status = 0;
}
- (void)loadNewComments{
NSMutableDictionary *params = [NSMutableDictionary dictionary];params[@"idProject"] = self.modelHome.idProject;
params[@"idType"] = @"7";
self.idBiz = self.modelHome.idProject;
[self.manager.requestSerializer setValue:setValue1 forHTTPHeaderField:Field1];
[self.manager.requestSerializer setValue:setValue2 forHTTPHeaderField:Field2];
[self.manager.requestSerializer setValue:setValue3 forHTTPHeaderField:Field3];
[self.manager.requestSerializer setValue:setValue4 forHTTPHeaderField:Field4];
[self.manager.requestSerializer setValue:self.string forHTTPHeaderField:@"Set-Cookie"];
[self.manager POST:IPaddress@"FileList.html" parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) {
} progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
// 隐藏指示器
NSLog(@"responseObject%@",responseObject);
//这个放ModelUpload1模型
self.attNameListArray = [NSMutableArray array];
//这个是最终你要的数据(LargeModel 模型)
self.largeModelArray = [NSMutableArray array];
//第一层 字典
for (NSDictionary *dic in responseObject[@"result"]) {
NSArray *attNameList = dic[@"attNameList"];
//第二层 attNameList里面(字典)
[self.attNameListArray removeAllObjects];
for (NSDictionary *attNameListDic in attNameList) {
ModelUpload1 *model1 = [[ModelUpload1 alloc]initWithDic:attNameListDic];
//存放ModelUpload1
[self.attNameListArray addObject:model1];
}
ModelUpload *model = [[ModelUpload alloc]init];
[model.attNameList addObjectsFromArray:self.attNameListArray];
model.nameStage = dic[@"nameStage"];
[self.largeModelArray addObject:model];
}
[self.tabelView2 reloadData];
[self.tabelView2.mj_header endRefreshing];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
UIAlertView *al = [[UIAlertView alloc]initWithTitle:@"请求失败" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];
[al show];
[self.tabelView2.mj_header endRefreshing];
}];
}
上面的代码是我讲这个将达模型里买放一个小模型,小模型里面放最底层那个字典数组里面的元素
大模型里面.h
#import <Foundation/Foundation.h>
@interface ModelUpload : NSObject
@property (nonatomic, strong)NSMutableArray *attNameList;
@property (nonatomic, copy) NSString *nameStage;
@end
.m里面的代码
#import "ModelUpload.h"
@implementation ModelUpload
-(NSMutableArray *)attNameList{
if (!_attNameList) {
_attNameList = [NSMutableArray array];
}
return _attNameList;
}
@end
小模型里.h
#import <Foundation/Foundation.h>
@interface ModelUpload1 : NSObject
@property(nonatomic,strong)NSString *idList;//~>idlist
@property(nonatomic,strong)NSString *remark;
@property(nonatomic,strong)NSString *attName;
@property(nonatomic,strong)NSString *fileCount;
- (instancetype)initWithDic:(NSDictionary *)dic;
@end
.m里面的代码
#import "ModelUpload1.h"
@implementation ModelUpload1
- (instancetype)initWithDic:(NSDictionary *)dic {
if (self = [super init]) {
self.idList = dic[@"idList"];
self.remark = dic[@"remark"];
self.attName = dic[@"attName"];
self.fileCount = dic[@"fileCount"];
}
return self;
}
@end
然后展示到tableView里买呢,附上全部的代码
#pragma mark - tableView的代理方法:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ModelUpload *lageModel = self.largeModelArray[section];
return lageModel.attNameList.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.tabelView2) {
UploadTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TableViewCellID2];
cell.delegate = self;
ModelUpload *lageModel = self.largeModelArray[indexPath.section];
ModelUpload1 *model = lageModel.attNameList[indexPath.row];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *file = [NSString stringWithFormat:@"%@",self.modelHome.customerName];
NSString *file1 = [NSString stringWithFormat:@"%@",lageModel.nameStage];
NSString *file2 = [NSString stringWithFormat:@"%@",model.attName];
self.myString = [NSString stringWithFormat:@"/%@/%@/%@",file,file1,file2];
NSString *myDirectory = [documentsDirectory stringByAppendingPathComponent:self.myString];
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isExist = [fileManager fileExistsAtPath:myDirectory];
cell.backgroundColor = [UIColor clearColor];
if (isExist) {
cell.imagVew.image = [UIImage imageNamed:@"attachment"];
}else{
cell.imagVew.image = [UIImage imageNamed:@""];
}
cell.label.text = model.attName;
cell.message.text = [NSString stringWithFormat:@"已有%@张",model.fileCount];
return cell;
}
return nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return self.largeModelArray.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == self.tabelView2) {
// 点击某一行时,创建一个新的控制器对象:
HBUploadViewController *svc = [[HBUploadViewController alloc] init];
ModelUpload *lageModel = self.largeModelArray[indexPath.section];
ModelUpload1 *model = lageModel.attNameList[indexPath.row];
svc.lageModel = lageModel;
svc.model = model;
svc.idBiz = self.idBiz;
svc.idList = model.idList;
svc.index1 = indexPath.row;
svc.modelHome = self.modelHome;
svc.fileCount = model.fileCount;
[self.navigationController pushViewController:svc animated:YES];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 44;
}
//16.段头视图:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (tableView == self.tabelView2) {
ViewHead *head = [[NSBundle mainBundle] loadNibNamed:@"ViewHead" owner:self options:nil][0];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 35, 35);
[button setBackgroundImage:[UIImage imageNamed:@"upload_normal_副本"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
button.tag = section;
head.userInteractionEnabled = YES;
[head.downView addSubview:button];
ModelUpload *largeModel = self.largeModelArray[section];
NSLog(@"largeModel.nameStage%@",largeModel.nameStage);
if ([largeModel.nameStage isEqual: @"<null>"]) {
return head;
}else{
head.titleLabel.text = largeModel.nameStage;
return head;
}
}
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 44;
}