- 循环引用的weak用法
// ** {} 中所有 self 都是弱引用,注意需要解包
// 1、类似于 OC 中的 __weak typeof(self) weakSelf = self;
weak var weakSelf = self test2 { (res) in print(res) weakSelf?.view.backgroundColor = UIColor.red }
// 2、[weak self]
test2 { [weak self] (res) in print(res) self?.view.backgroundColor = UIColor.orange }
func test2(com: (_ :String)->()) { let str = "---- test2 ----" com(str) }