From 4b17ec6b51cc3e434f7cd4a2399f7543314e2dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ce=CC=81dric=20Luthi?= Date: Fri, 1 Feb 2013 12:23:26 +0100 Subject: [PATCH] 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. --- AFNetworking/UIImageView+AFNetworking.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index 74bac53..fd0e071 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -114,7 +114,7 @@ static char kAFImageRequestOperationObjectKey; AFImageRequestOperation *requestOperation = [[AFImageRequestOperation alloc] initWithRequest:urlRequest]; [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { - if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { if (success) { success(operation.request, operation.response, responseObject); } else { @@ -128,7 +128,7 @@ static char kAFImageRequestOperationObjectKey; [[[self class] af_sharedImageCache] cacheImage:responseObject forRequest:urlRequest]; } failure:^(AFHTTPRequestOperation *operation, NSError *error) { - if ([[urlRequest URL] isEqual:[[self.af_imageRequestOperation request] URL]]) { + if ([urlRequest isEqual:[self.af_imageRequestOperation request]]) { if (failure) { failure(operation.request, operation.response, error); }