Do not capture self in operations in categories

This commit is contained in:
Olivier Poitrey 2012-11-28 00:39:58 +01:00
parent 10c44577f6
commit 82faab82d3
3 changed files with 17 additions and 5 deletions

View File

@ -46,11 +46,14 @@ static char operationKey;
if (url)
{
__weak MKAnnotationView *wself = self;
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, BOOL fromCache, BOOL finished)
{
__strong MKAnnotationView *sself = wself;
if (!sself) return;
if (image)
{
self.image = image;
sself.image = image;
}
if (completedBlock && finished)
{

View File

@ -45,11 +45,14 @@ static char operationKey;
if (url)
{
__weak UIButton *wself = self;
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
{
__strong UIButton *sself = wself;
if (!sself) return;
if (image)
{
[self setImage:image forState:state];
[sself setImage:image forState:state];
}
if (completedBlock && finished)
{
@ -93,11 +96,14 @@ static char operationKey;
if (url)
{
__weak UIButton *wself = self;
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
{
__strong UIButton *sself = wself;
if (!sself) return;
if (image)
{
[self setBackgroundImage:image forState:state];
[sself setBackgroundImage:image forState:state];
}
if (completedBlock && finished)
{

View File

@ -51,12 +51,15 @@ static char operationKey;
if (url)
{
__weak UIImageView *wself = self;
id<SDWebImageOperation> operation = [SDWebImageManager.sharedManager downloadWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished)
{
__strong UIImageView *sself = wself;
if (!sself) return;
if (image)
{
self.image = image;
[self setNeedsLayout];
sself.image = image;
[sself setNeedsLayout];
}
if (completedBlock && finished)
{