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

 N021039 发布于 2022-10-27 12:28
  • (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];
    2022-10-27 23:09 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有