objective-c - afnetworking从接口中得到数据,怎么把数据放在另外的变量里呢
过去多啦不再A梦
过去多啦不再A梦 2017-05-02 09:30:03
0
1
548
  • (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);
        
    }];
    

    }

    }

过去多啦不再A梦
过去多啦不再A梦

membalas semua(1)
过去多啦不再A梦

Sirialisasi? Anda telah pun melakukan baris kod ini:

SVJSONModel *jsonModel = [[SVJSONModel alloc]initWithDictionary:resultDic error:nil];
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan