objective-c - afnetworking从接口中得到数据,怎么把数据放在另外的变量里呢

浏览:52日期:2023-11-24

问题描述

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

}

}

问题解答

回答1:

序列化?你这行代码已经做了啊:

SVJSONModel *jsonModel = [[SVJSONModel alloc]initWithDictionary:resultDic error:nil];

相关文章: