Use __typeof(self) when assigning weak reference for block.
Signed-off-by: 庞博 <bopang@sohu-inc.com>
This commit is contained in:
parent
9cc8269dcd
commit
f83abb578a
|
@ -45,7 +45,7 @@ static char imageURLKey;
|
|||
self.image = placeholder;
|
||||
|
||||
if (url) {
|
||||
__weak MKAnnotationView *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
|
|
|
@ -113,7 +113,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
|
|||
|
||||
- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
|
||||
__block SDWebImageDownloaderOperation *operation;
|
||||
__weak SDWebImageDownloader *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
|
||||
[self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{
|
||||
NSTimeInterval timeoutInterval = wself.downloadTimeout;
|
||||
|
|
|
@ -68,7 +68,7 @@ static char imageURLStorageKey;
|
|||
|
||||
self.imageURLStorage[@(state)] = url;
|
||||
|
||||
__weak UIButton *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
|
@ -111,7 +111,7 @@ static char imageURLStorageKey;
|
|||
[self setBackgroundImage:placeholder forState:state];
|
||||
|
||||
if (url) {
|
||||
__weak UIButton *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
[self sd_cancelCurrentHighlightedImageLoad];
|
||||
|
||||
if (url) {
|
||||
__weak UIImageView *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe (^
|
||||
|
|
|
@ -49,7 +49,7 @@ static char imageURLKey;
|
|||
}
|
||||
|
||||
if (url) {
|
||||
__weak UIImageView *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
id <SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
|
||||
if (!wself) return;
|
||||
dispatch_main_sync_safe(^{
|
||||
|
@ -92,7 +92,7 @@ static char imageURLKey;
|
|||
|
||||
- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
|
||||
[self sd_cancelCurrentAnimationImagesLoad];
|
||||
__weak UIImageView *wself = self;
|
||||
__weak __typeof(self)wself = self;
|
||||
|
||||
NSMutableArray *operationsArray = [[NSMutableArray alloc] init];
|
||||
|
||||
|
|
Loading…
Reference in New Issue