美文网首页
Capturing 'self' strongl

Capturing 'self' strongl

作者: BlueBar | 来源:发表于2017-06-07 15:23 被阅读12次

block 是代码块的意思。 甲里引用乙,乙里引用甲,就会导致 “retain cycle” -- “形成怪圈”的错误。

_customBarView.CallBack=^(UIButton *sender, NSInteger i){
        [self  jump:sender and:i];
    };

​```

self 转换一下加上__block字段就不会被retain了

__block creatTabBarController *controller = self;

_customBarView.CallBack=^(UIButton *sender, NSInteger i){

    [controller jump:sender and:i];
};

相关文章

网友评论

      本文标题:Capturing 'self' strongl

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