1

I create the custom cell with the activity indicator view With using the SDWebImage I hidden the activity indicator when the image is downloaded

[customCell.userPhotoImageView setImageWithURL:[NSURL URLWithString:[[thisNotify user]imageURL]] placeholderImage:nil completed:^
 (UIImage *image, NSError *error, SDImageCacheType cacheType)
 {
     customCell.activityView.hidden = TRUE;
 }];

But I execute the code I look this warning

Capturing 'customCell' strongly in this block is likely to lead to a retain cycle

Thanks

newacct
  • 119,665
  • 29
  • 163
  • 224

1 Answers1

2

You can try something like this just before that block call:

__weak UICustomCell * weakCustomCell = customCell;
[customCell.userPhotoImageView setImageWithURL:....^{
   weakCustomCell.activityView.hidden = YES;
}];

I think that will fix the error. You just assign a new weakly referenced object to your cell, which should prevent the retain cycle. Not entirely sure of the reasoning behind it, but worth a shot.

edit here's a potential explanation though

Community
  • 1
  • 1
Louis Tur
  • 1,303
  • 10
  • 16