diff --git a/SDWebImage/SDWebImageDownloader.m b/SDWebImage/SDWebImageDownloader.m index ac552219..be1a9e92 100644 --- a/SDWebImage/SDWebImageDownloader.m +++ b/SDWebImage/SDWebImageDownloader.m @@ -151,8 +151,8 @@ NSString *const kCompletedCallbackKey = @"completed"; // Handle single download of simultaneous download request for the same URL NSMutableArray *callbacksForURL = self.URLCallbacks[url]; NSMutableDictionary *callbacks = NSMutableDictionary.new; - if (progressBlock) callbacks[kProgressCallbackKey] = progressBlock; - if (completedBlock) callbacks[kCompletedCallbackKey] = completedBlock; + if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy]; + if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy]; [callbacksForURL addObject:callbacks]; self.URLCallbacks[url] = callbacksForURL; diff --git a/SDWebImage/SDWebImageDownloaderOperation.m b/SDWebImage/SDWebImageDownloaderOperation.m index 8e0304c8..0af2733d 100644 --- a/SDWebImage/SDWebImageDownloaderOperation.m +++ b/SDWebImage/SDWebImageDownloaderOperation.m @@ -12,9 +12,9 @@ @interface SDWebImageDownloaderOperation () -@property (strong, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; -@property (strong, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; -@property (strong, nonatomic) void (^cancelBlock)(); +@property (copy, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; +@property (copy, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; +@property (copy, nonatomic) void (^cancelBlock)(); @property (assign, nonatomic, getter = isExecuting) BOOL executing; @property (assign, nonatomic, getter = isFinished) BOOL finished; @@ -37,9 +37,9 @@ _queue = queue; _request = request; _options = options; - _progressBlock = progressBlock; - _completedBlock = completedBlock; - _cancelBlock = cancelBlock; + _progressBlock = [progressBlock copy]; + _completedBlock = [completedBlock copy]; + _cancelBlock = [cancelBlock copy]; _executing = NO; _finished = NO; _expectedSize = 0; diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index 58971724..4e3e6a4c 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -12,7 +12,7 @@ @interface SDWebImageCombinedOperation : NSObject @property (assign, nonatomic, getter = isCancelled) BOOL cancelled; -@property (strong, nonatomic) void (^cancelBlock)(); +@property (copy, nonatomic) void (^cancelBlock)(); @end @@ -146,7 +146,7 @@ } else { - _cancelBlock = cancelBlock; + _cancelBlock = [cancelBlock copy]; } }