美文网首页iOS
__weak typeof(self)weakSelf = se

__weak typeof(self)weakSelf = se

作者: 习惯了_就好 | 来源:发表于2020-06-18 14:34 被阅读0次

typeof(self)获取self的类型;
typeof(self)weakSelf 定义一个self类型的变量;
typeof(self)weakSelf = self 将self赋值给typeof(self)weakSelf的变量;
__weak typeof(self)weakSelf = self 将该变量置为弱引用类型。

UIButton * btn1 = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton * btn2 = [UIButton buttonWithType:UIButtonTypeCustom];
__weak typeof(btn1) btn3 = btn2;
类似定义一个btn3并用btn2初始化它

相关文章

网友评论

    本文标题:__weak typeof(self)weakSelf = se

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