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);
NSLog(@"error:%@",error);
}else{
model的赋值
}
}];
}];
[task resume];
}
贴上代码以GET请求为例: