Skip to content

Commit

Permalink
Merge pull request SDWebImage#1054 from heistings/develop
Browse files Browse the repository at this point in the history
Use __typeof(self) when assigning weak reference for block.
  • Loading branch information
bpoplauschi committed Mar 19, 2015
2 parents eac0b81 + f83abb5 commit d56c4f3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion SDWebImage/MKAnnotationView+WebCache.m
Expand Up @@ -45,7 +45,7 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
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(^{
Expand Down
2 changes: 1 addition & 1 deletion SDWebImage/SDWebImageDownloader.m
Expand Up @@ -110,7 +110,7 @@ - (void)setOperationClass:(Class)operationClass {

- (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;
Expand Down
4 changes: 2 additions & 2 deletions SDWebImage/UIButton+WebCache.m
Expand Up @@ -68,7 +68,7 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold

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(^{
Expand Down Expand Up @@ -111,7 +111,7 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
[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(^{
Expand Down
2 changes: 1 addition & 1 deletion SDWebImage/UIImageView+HighlightedWebCache.m
Expand Up @@ -33,7 +33,7 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
[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 (^
Expand Down
4 changes: 2 additions & 2 deletions SDWebImage/UIImageView+WebCache.m
Expand Up @@ -49,7 +49,7 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
}

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(^{
Expand Down Expand Up @@ -92,7 +92,7 @@ - (NSURL *)sd_imageURL {

- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
[self sd_cancelCurrentAnimationImagesLoad];
__weak UIImageView *wself = self;
__weak __typeof(self)wself = self;

NSMutableArray *operationsArray = [[NSMutableArray alloc] init];

Expand Down

0 comments on commit d56c4f3

Please sign in to comment.