问题
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
回答1:
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
来源:https://stackoverflow.com/questions/27335587/strongly-in-this-block-is-likely-to-lead-to-a-retain-cycle