AFHTTPSessionManager *manager=[AFHTTPSessionManager manager];
//设置默认请求类型(NSData)
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[managerGET:self.urlparameters:nilprogress:^(NSProgress*_NonnulldownloadProgress) {
}success:^(NSURLSessionDataTask*_Nonnulltask,id _NullableresponseObject) {
//解析数据
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil];
NSArray*resultarr=dic[self.Key];
for(NSDictionary*diccinresultarr) {
//封装model,建立数据模型
basemodel*model=[[basemodelalloc]init];
[modelsetValuesForKeysWithDictionary:dicc];
[self.datasourceaddObject:model];
}
[self.tableviewreloadData];
//取消刷新控件
[self.tableview.mj_headerendRefreshing];
[self.tableview.mj_footerendRefreshing];
//去掉加载栏
[SVProgressHUD dismiss];
}failure:^(NSURLSessionDataTask*_Nullabletask,NSError*_Nonnullerror) {
//提示用户
//取消刷新控件
[self.tableview.mj_headerendRefreshing];
[self.tableview.mj_footerendRefreshing];
//去掉加载栏
[SVProgressHUD dismiss];
}];
网友评论