ios swift [weak self]

  • 使用实例
  @objc func phoneBtnClick(){
    
    
        let vc = EWCountryCodeViewController()
        vc.backCountryCode = {
    
     [weak self] country, code in
            self?.phoneBtn.setTitle("+"+code, for: .normal)
        }
        present(vc, animated: true, completion: nil)
    }

相关博客:
Swift 闭包无脑加 [weak self] 行不行? - 知乎
关于 Swift 闭包上下文捕获的官方文档导读 - 知乎

猜你喜欢

转载自blog.csdn.net/baidu_40537062/article/details/123675679