Copy all stored blocks

This commit is contained in:
Olivier Poitrey 2012-11-09 11:05:18 +01:00
parent 8f50bf6322
commit 7b947163da
3 changed files with 10 additions and 10 deletions

View File

@ -151,8 +151,8 @@ NSString *const kCompletedCallbackKey = @"completed";
// Handle single download of simultaneous download request for the same URL // Handle single download of simultaneous download request for the same URL
NSMutableArray *callbacksForURL = self.URLCallbacks[url]; NSMutableArray *callbacksForURL = self.URLCallbacks[url];
NSMutableDictionary *callbacks = NSMutableDictionary.new; NSMutableDictionary *callbacks = NSMutableDictionary.new;
if (progressBlock) callbacks[kProgressCallbackKey] = progressBlock; if (progressBlock) callbacks[kProgressCallbackKey] = [progressBlock copy];
if (completedBlock) callbacks[kCompletedCallbackKey] = completedBlock; if (completedBlock) callbacks[kCompletedCallbackKey] = [completedBlock copy];
[callbacksForURL addObject:callbacks]; [callbacksForURL addObject:callbacks];
self.URLCallbacks[url] = callbacksForURL; self.URLCallbacks[url] = callbacksForURL;

View File

@ -12,9 +12,9 @@
@interface SDWebImageDownloaderOperation () @interface SDWebImageDownloaderOperation ()
@property (strong, nonatomic) SDWebImageDownloaderProgressBlock progressBlock; @property (copy, nonatomic) SDWebImageDownloaderProgressBlock progressBlock;
@property (strong, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock; @property (copy, nonatomic) SDWebImageDownloaderCompletedBlock completedBlock;
@property (strong, nonatomic) void (^cancelBlock)(); @property (copy, nonatomic) void (^cancelBlock)();
@property (assign, nonatomic, getter = isExecuting) BOOL executing; @property (assign, nonatomic, getter = isExecuting) BOOL executing;
@property (assign, nonatomic, getter = isFinished) BOOL finished; @property (assign, nonatomic, getter = isFinished) BOOL finished;
@ -37,9 +37,9 @@
_queue = queue; _queue = queue;
_request = request; _request = request;
_options = options; _options = options;
_progressBlock = progressBlock; _progressBlock = [progressBlock copy];
_completedBlock = completedBlock; _completedBlock = [completedBlock copy];
_cancelBlock = cancelBlock; _cancelBlock = [cancelBlock copy];
_executing = NO; _executing = NO;
_finished = NO; _finished = NO;
_expectedSize = 0; _expectedSize = 0;

View File

@ -12,7 +12,7 @@
@interface SDWebImageCombinedOperation : NSObject <SDWebImageOperation> @interface SDWebImageCombinedOperation : NSObject <SDWebImageOperation>
@property (assign, nonatomic, getter = isCancelled) BOOL cancelled; @property (assign, nonatomic, getter = isCancelled) BOOL cancelled;
@property (strong, nonatomic) void (^cancelBlock)(); @property (copy, nonatomic) void (^cancelBlock)();
@end @end
@ -146,7 +146,7 @@
} }
else else
{ {
_cancelBlock = cancelBlock; _cancelBlock = [cancelBlock copy];
} }
} }