iOS

__weak typeof(self)weakSelf = se

2020-06-18  本文已影响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初始化它

上一篇 下一篇

猜你喜欢

热点阅读