强在这个块很可能会导致一个retain循环 [英] Strongly in this block is likely to lead to a retain cycle

查看:99
本文介绍了强在这个块很可能会导致一个retain循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用活动指示器视图创建自定义单元格通过使用 SDWebImage,我在下载图像时隐藏了活动指示器

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

在这个块中强烈捕获'customCell'很可能会导致一个retain cycle

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

谢谢

推荐答案

你可以在那个块调用之前尝试这样的事情:

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.

编辑 这里有一个可能的解释

这篇关于强在这个块很可能会导致一个retain循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆