Swift解决循环引用问题

循环引用一般是存在于block(闭包)里面,是在block(闭包)大括号里面加上[weak self]即可,访问self时候,会有问号出现,弱引用的代表:

 private lazy var popoverAnimation: PLPopoverAnimation = PLPopoverAnimation {[weak self] (presented) in
    self?.titleBtn.isSelected = presented
}

你可能感兴趣的:(Swift解决循环引用问题)