Reputation: 33644
I am using AFNetworking's UIImageView category and I am constantly getting a response code of 0 in my response code status. Any idea why this is? Here's how I am doing it:
[self.newsPicture_ setImageWithURLRequest:storyImageRequest
placeholderImage:nil
success:^(NSURLRequest * request, NSHTTPURLResponse * response, UIImage * image) {
if ([response statusCode] == 200){
dispatch_async(dispatch_get_main_queue(), ^(void){
});
} else {
NSLog(@"RESPONSE ERROR WITH CODE IS %d", [response statusCode]);
}
}failure:^(NSURLRequest * request, NSHTTPURLResponse * response, NSError * error){
if (error){
NSLog(@"Error in requesting news story image");
}
}];
Any idea why this might be happening?
This is only happening when I am using the block based function call.
When I use setImageWithURL, everything works fine
Upvotes: 2
Views: 2026
Reputation: 19544
UIImageView+AFNetworking
uses an internal cache to optimize performance in scroll views and table views. A response code of 0 means that the image came out of that internal cache without making an HTTP request. You shouldn't need to check the status code being 200 in success
, as that's already what the success/failure distinction is doing.
Upvotes: 8