iOS AFNetWorking 3.1 的网络解析

 

AFNetworking 3.0中废弃:

  • AFURLConnectionOperation
  • AFHTTPRequestOperation
  • AFHTTPRequestOperationManager
    NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
 
    AFURLSessionManager *manage = [[AFURLSessionManager alloc]initWithSessionConfiguration:configuration];
 
    NSMutableURLRequest *reguest = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" 或者@"POST"  URLString:[NSString stringWithFormat:@"网址"]  parameters:nil error:nil];
 
    manage.responseSerializer = [AFHTTPResponseSerializer serializer];
 
 NSURLSessionDataTask *task = [manage dataTaskWithRequest:reguest completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
        if (error) {
            NSLog(@"error:%@",error);
        }else{
          model的赋值  
        }
    }];
    [task resume];
}
 
贴上代码以GET请求为例:
 

 

posted @ 2016-07-07 10:39  小小鸟菜  阅读(371)  评论(0编辑  收藏  举报