Compare NSURLRequest rather than NSURL
If you inadvertently load a nil URL in UIImageView+AFNetworking, the failure block of the image request operation is bypassed because [nil isEqual:nil] == NO. By comparing the URL request instead of the URL, the `isEqual:` test passes and the error is properly forwarded to the failure block parameter.
This commit is contained in:
parent
22c7d4ec96
commit
4b17ec6b51
1 changed files with 2 additions and 2 deletions
|
|
@ -114,7 +114,7 @@ static char kAFImageRequestOperationObjectKey;
|
||||||
|
|
||||||
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
|
AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest];
|
||||||
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
|
||||||
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
|
if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) {
|
||||||
if (success) {
|
if (success) {
|
||||||
success(operation.request, operation.response, responseObject);
|
success(operation.request, operation.response, responseObject);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -128,7 +128,7 @@ static char kAFImageRequestOperationObjectKey;
|
||||||
|
|
||||||
[[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest];
|
[[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest];
|
||||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||||
if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) {
|
if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) {
|
||||||
if (failure) {
|
if (failure) {
|
||||||
failure(operation.request, operation.response, error);
|
failure(operation.request, operation.response, error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue