Merge pull request #2651 from Insofan/5.x
Clean some code to weakify && strongify macros which is depened on pr #2647
This commit is contained in:
commit
bdd4667f4c
|
@ -54,13 +54,14 @@
|
|||
context:(nullable SDWebImageContext *)context
|
||||
progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
||||
completed:(nullable SDExternalCompletionBlock)completedBlock {
|
||||
__weak typeof(self)weakSelf = self;
|
||||
@weakify(self);
|
||||
[self sd_internalSetImageWithURL:url
|
||||
placeholderImage:placeholder
|
||||
options:options
|
||||
context:context
|
||||
setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
weakSelf.image = image;
|
||||
@strongify(self);
|
||||
self.image = image;
|
||||
}
|
||||
progress:progressBlock
|
||||
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
|
|
|
@ -121,13 +121,14 @@ static NSString * const SDAlternateImageOperationKey = @"NSButtonAlternateImageO
|
|||
mutableContext = [NSMutableDictionary dictionary];
|
||||
}
|
||||
mutableContext[SDWebImageContextSetImageOperationKey] = SDAlternateImageOperationKey;
|
||||
__weak typeof(self)weakSelf = self;
|
||||
@weakify(self);
|
||||
[self sd_internalSetImageWithURL:url
|
||||
placeholderImage:placeholder
|
||||
options:options
|
||||
context:mutableContext
|
||||
setImageBlock:^(NSImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
weakSelf.alternateImage = image;
|
||||
@strongify(self);
|
||||
self.alternateImage = image;
|
||||
}
|
||||
progress:progressBlock
|
||||
completed:^(NSImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
|
|
|
@ -104,13 +104,14 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
|
|||
mutableContext = [NSMutableDictionary dictionary];
|
||||
}
|
||||
mutableContext[SDWebImageContextSetImageOperationKey] = imageOperationKeyForState(state);
|
||||
__weak typeof(self)weakSelf = self;
|
||||
@weakify(self);
|
||||
[self sd_internalSetImageWithURL:url
|
||||
placeholderImage:placeholder
|
||||
options:options
|
||||
context:mutableContext
|
||||
setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
[weakSelf setImage:image forState:state];
|
||||
@strongify(self);
|
||||
[self setImage:image forState:state];
|
||||
}
|
||||
progress:progressBlock
|
||||
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
|
@ -188,13 +189,14 @@ static inline NSString * backgroundImageOperationKeyForState(UIControlState stat
|
|||
mutableContext = [NSMutableDictionary dictionary];
|
||||
}
|
||||
mutableContext[SDWebImageContextSetImageOperationKey] = imageOperationKeyForState(state);
|
||||
__weak typeof(self)weakSelf = self;
|
||||
@weakify(self);
|
||||
[self sd_internalSetImageWithURL:url
|
||||
placeholderImage:placeholder
|
||||
options:options
|
||||
context:mutableContext
|
||||
setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
[weakSelf setBackgroundImage:image forState:state];
|
||||
@strongify(self);
|
||||
[self setBackgroundImage:image forState:state];
|
||||
}
|
||||
progress:progressBlock
|
||||
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
|
|
|
@ -46,7 +46,7 @@ static NSString * const SDHighlightedImageOperationKey = @"UIImageViewImageOpera
|
|||
context:(nullable SDWebImageContext *)context
|
||||
progress:(nullable SDImageLoaderProgressBlock)progressBlock
|
||||
completed:(nullable SDExternalCompletionBlock)completedBlock {
|
||||
__weak typeof(self)weakSelf = self;
|
||||
@weakify(self);
|
||||
SDWebImageMutableContext *mutableContext;
|
||||
if (context) {
|
||||
mutableContext = [context mutableCopy];
|
||||
|
@ -59,7 +59,8 @@ static NSString * const SDHighlightedImageOperationKey = @"UIImageViewImageOpera
|
|||
options:options
|
||||
context:mutableContext
|
||||
setImageBlock:^(UIImage * _Nullable image, NSData * _Nullable imageData, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
|
||||
weakSelf.highlightedImage = image;
|
||||
@strongify(self);
|
||||
self.highlightedImage = image;
|
||||
}
|
||||
progress:progressBlock
|
||||
completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
|
||||
|
|
Loading…
Reference in New Issue