美文网首页
4.Block中调用成员函数 retain cycle

4.Block中调用成员函数 retain cycle

作者: Jingwei | 来源:发表于2014-04-09 14:26 被阅读56次

原因:

我也不知道,可能引用技术的问题吧。

解决:

错误:

    _avatar.touchBlock = ^{
        [self showMenu]; // Capturing 'self' strongly in this block is likely to lead to retain cycle
    };

正确:

    __weak id weakSelf = self;
    _avatar.touchBlock = ^{
        [weakSelf showMenu]; // it's OK
    };

要说的话:

这里面闹不清楚,我也不想闹清楚,oc我只是写app而已,不想研究的多深,不过根据个人感觉,应该是智能指针 shared_per weak_ptr那些东西造成的。

相关文章

网友评论

      本文标题:4.Block中调用成员函数 retain cycle

      本文链接:https://www.haomeiwen.com/subject/stdltttx.html