Merge pull request #1054 from heistings/develop

Use __typeof(self) when assigning weak reference for block.
This commit is contained in:
Bogdan Poplauschi 2015-03-19 14:19:58 +02:00
commit d56c4f3d22
5 changed files with 7 additions and 7 deletions

View File

@ -45,7 +45,7 @@ static char imageURLKey;
self.image = placeholder; self.image = placeholder;
if (url) { 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) { 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; if (!wself) return;
dispatch_main_sync_safe(^{ dispatch_main_sync_safe(^{

View File

@ -110,7 +110,7 @@ static NSString *const kCompletedCallbackKey = @"completed";
- (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock { - (id <SDWebImageOperation>)downloadImageWithURL:(NSURL *)url options:(SDWebImageDownloaderOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageDownloaderCompletedBlock)completedBlock {
__block SDWebImageDownloaderOperation *operation; __block SDWebImageDownloaderOperation *operation;
__weak SDWebImageDownloader *wself = self; __weak __typeof(self)wself = self;
[self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{ [self addProgressCallback:progressBlock andCompletedBlock:completedBlock forURL:url createCallback:^{
NSTimeInterval timeoutInterval = wself.downloadTimeout; NSTimeInterval timeoutInterval = wself.downloadTimeout;

View File

@ -68,7 +68,7 @@ static char imageURLStorageKey;
self.imageURLStorage[@(state)] = url; 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) { 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; if (!wself) return;
dispatch_main_sync_safe(^{ dispatch_main_sync_safe(^{
@ -111,7 +111,7 @@ static char imageURLStorageKey;
[self setBackgroundImage:placeholder forState:state]; [self setBackgroundImage:placeholder forState:state];
if (url) { 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) { 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; if (!wself) return;
dispatch_main_sync_safe(^{ dispatch_main_sync_safe(^{

View File

@ -33,7 +33,7 @@
[self sd_cancelCurrentHighlightedImageLoad]; [self sd_cancelCurrentHighlightedImageLoad];
if (url) { 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) { 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; if (!wself) return;
dispatch_main_sync_safe (^ dispatch_main_sync_safe (^

View File

@ -49,7 +49,7 @@ static char imageURLKey;
} }
if (url) { 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) { 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; if (!wself) return;
dispatch_main_sync_safe(^{ dispatch_main_sync_safe(^{
@ -92,7 +92,7 @@ static char imageURLKey;
- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
[self sd_cancelCurrentAnimationImagesLoad]; [self sd_cancelCurrentAnimationImagesLoad];
__weak UIImageView *wself = self; __weak __typeof(self)wself = self;
NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; NSMutableArray *operationsArray = [[NSMutableArray alloc] init];