我正在尝试以这种方式使用 AFNetworking 3.0 下载图像:
- (UIImage *) loadImage:(NSString *) link
{
__block UIImage *image = [UIImage imageNamed:@"no_user_profile_pic.png"];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFImageResponseSerializer serializer];
[manager GET:[link stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet]]
parameters:nil
progress:nil
success:^(NSURLSessionTask *task, id responseObject) {
image = (UIImage *) responseObject;
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Load Image error - %@", [error description]);
}];
return image;
}
每次我收到此错误时:
*** -[AFHTTPRequestSerializer requestWithMethod:URLString:parameters:error:] 中的断言失败,/Users/.../AFNetworking/AFURLRequestSerialization.m:353
我无法弄清楚我做错了什么。发生了什么错误?