Swift与OC差异 - 基础概念
作者:
FansX | 来源:发表于
2018-11-23 14:48 被阅读0次弱引用、强引用
__weak typeof(self) weakSelf = self
__strong typeof(weakSelf) strongSelf = weakSelf // 用于弱引用可能在闭包中销毁self的情况
[weak self]
guard let strongSelf = self else { return } // 用于弱引用可能在闭包中销毁self的情况
懒加载
-(UILabel*)nickLabel {
if(nickLabel == nil) {
UILabel *nick = [[UILabel alloc] init];
}
return nick;
}
lazy var nickLabel: UILabel = {
let nick = UILabel()
return nick
}()
本文标题:Swift与OC差异 - 基础概念
本文链接:https://www.haomeiwen.com/subject/jctjqqtx.html
网友评论