I have integrated the AFNetworking library in my app to download images from a URL and the app is crashing when we are loading multiple images.
When I analyse my code using the Xcode crash report list (Xcode -> Window -> Organizer -> Crashes -> Our app), it is showing an error in the AFNetworking library for this line of code:
Class:
UIImageView+AFNetworking
Method Name:
setImageWithURLRequest
Line of code:
[[[self class] af_sharedImageRequestOperationQueue] addOperation:self.af_imageRequestOperation];
Can anyone help me sort out this problem?
Try the following code
NSURL *url = [NSURL URLWithString:@"YourImageURL"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
UIImage *placeholderImage = [UIImage imageNamed:@"placeholder"];
__weak UIImageView *weakImageView = yourImageView;
[weakImageView setImageWithURLRequest:request
placeholderImage:placeholderImage
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
weakImageView.image = image;
} failure:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With