diff --git a/AFNetworking/AFImageRequestOperation.m b/AFNetworking/AFImageRequestOperation.m index 9e7e956..9e2ba89 100644 --- a/AFNetworking/AFImageRequestOperation.m +++ b/AFNetworking/AFImageRequestOperation.m @@ -81,7 +81,6 @@ static dispatch_queue_t image_request_operation_processing_queue() { if (success) { dispatch_async(dispatch_get_main_queue(), ^(void) { - success(operation.request, operation.response, image); }); } @@ -90,7 +89,7 @@ static dispatch_queue_t image_request_operation_processing_queue() { [[AFImageCache sharedImageCache] cacheImage:image forURL:[operation.request URL] cacheName:cacheNameOrNil]; } } - }); + }); }; return operation; diff --git a/AFNetworking/UIImageView+AFNetworking.m b/AFNetworking/UIImageView+AFNetworking.m index ba880c4..74f718b 100644 --- a/AFNetworking/UIImageView+AFNetworking.m +++ b/AFNetworking/UIImageView+AFNetworking.m @@ -27,7 +27,7 @@ #import "AFImageCache.h" -static NSString * const kAFImageRequestOperationObjectKey = @"_af_imageRequestOperation"; +static char kAFImageRequestOperationObjectKey; @interface UIImageView (_AFNetworking) @property (readwrite, nonatomic, retain, setter = af_setImageRequestOperation:) AFImageRequestOperation *af_imageRequestOperation; @@ -42,11 +42,11 @@ static NSString * const kAFImageRequestOperationObjectKey = @"_af_imageRequestOp @implementation UIImageView (AFNetworking) - (AFHTTPRequestOperation *)af_imageRequestOperation { - return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, kAFImageRequestOperationObjectKey); + return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, &kAFImageRequestOperationObjectKey); } - (void)af_setImageRequestOperation:(AFImageRequestOperation *)imageRequestOperation { - objc_setAssociatedObject(self, kAFImageRequestOperationObjectKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + objc_setAssociatedObject(self, &kAFImageRequestOperationObjectKey, imageRequestOperation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } + (NSOperationQueue *)af_sharedImageRequestOperationQueue { @@ -97,7 +97,7 @@ static NSString * const kAFImageRequestOperationObjectKey = @"_af_imageRequestOp } else { self.image = placeholderImage; - self.af_imageRequestOperation = [AFImageRequestOperation imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { + self.af_imageRequestOperation = [AFImageRequestOperation imageRequestOperationWithRequest:urlRequest imageProcessingBlock:nil cacheName:nil success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) { if (self.af_imageRequestOperation && ![self.af_imageRequestOperation isCancelled]) { if (success) { success(request, response, image); @@ -108,7 +108,7 @@ static NSString * const kAFImageRequestOperationObjectKey = @"_af_imageRequestOp } else { self.image = placeholderImage; } - } + } } failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) { self.af_imageRequestOperation = nil;