Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Provide URL request to the success block when images are retrieved from cache #2771

Merged

Conversation

chrisgibbs
Copy link

When UIImageView+AFNetworking successfully retrieves an image from the cache, the URL request was not being provided to the success block along with the image. This meant that there was no way to compare retrieved image's URL with the URL that should be displayed.

@kcharwood
Copy link
Contributor

Thanks @chrisgibbs. I think this makes sense. I'd like to see a test added to verify the behavior going forward.

setImageWithURLRequest:self.cachedImageRequest
placeholderImage:nil
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
XCTAssertEqual(request, weakSelf.cachedImageRequest, @"URL requests do not match");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert that the response IS nil? I believe that is what indicates the image returned from cache, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. I'll make sure that's documented as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good now.

@kcharwood kcharwood modified the milestones: 2.5.5, 2.6.0 Jun 26, 2015
kcharwood added a commit that referenced this pull request Jul 24, 2015
…param

Provide URL request to the success block when images are retrieved from cache
@kcharwood kcharwood merged commit cd675b6 into AFNetworking:master Jul 24, 2015
@kcharwood
Copy link
Contributor

All tests pass locally. Thanks for the PR!

🍻

Note I'll want to make sure this behavior change is explicitly called out in the Release Notes.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants