Search code examples
iosimageafnetworking-3

AfNetworking image loading issue


I am having a little trouble implementing the AFNetworking 3.0 image loading method. This is the way I am trying to use it. Can anyone tell me what am I doing wrong?

[self.imageView setImageWithURLRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.imageURL]] placeholderImage:nil  success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){
    self.imageView.image = image;
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
    NSLog(@"Unable to retrieve image");
}];

It is giving me compile time error which is:

No Visible @interface for 'UIImageView' declares the selector 'setImageWithURLRequest:placeHolder:success:failure


Solution

  • Import this file : UIImageView+AFNetworking.h.

    This includes the method setImageWithURLRequest:placeHolder:success:failure method.