佚名通过本文主要向大家介绍了afnetworking,afnetworking原理,afnetworking使用,ios afnetworking,afnetworking3.0等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: afnetworking从接口中得到数据,怎么把数据放在另外的变量里呢
描述:
解决方案1:
描述:
(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];