(NSArray *)model{
if (_model == nil) {
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
NSString *domainStr = @"http://122.200.77.206:8899/ishop/ePlatform/mobile/queryAllMerchants.do";
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.requestSerializer = [AFHTTPRequestSerializer serializer];
manager.responseSerializer = [AFHTTPResponseSerializer serializer];
[manager GET:domainStr parameters:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) {
// 隐藏系统风火轮
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
//json解析
NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableLeaves error:nil];
// NSLog(@"%@",resultDic);
SVJSONModel *jsonModel = [[SVJSONModel alloc]initWithDictionary:resultDic error:nil];
return jsonModel.data;
} failure:^(NSURLSessionDataTask * _Nonnull task, NSError * _Nonnull error) {
// 解析失败隐藏系统风火轮(可以打印error.userInfo查看错误信息)
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
NSLog(@"%@",error.userInfo);
}];
}
}
Sirialisasi? Anda telah pun melakukan baris kod ini: