在 v2 中,您收到AFHTTPRequestOperation
了请求
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
但是在 v3 中你会得到NSURLSessionTask
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:@"http://example.com/resources.json" parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSLog(@"JSON: %@", responseObject);
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
因此,基于此,您可以从之NSURLSessionTask
类的currentRequest
等处response
获取详细信息
更多变化和细节可以参考AFNetworking
AFNetworking Migration Guide的迁移指南
对于 NSURLSessionTask 参考:NSURLSessionTask