Swift Closures - Capturing self as weak

后端 未结 3 1723
春和景丽
春和景丽 2020-12-29 09:32

I am trying to resolve a closure based strong reference cycle in Swift.
In the code below, object is retained by the owning view controller. ProgressHUD is

3条回答
  •  感情败类
    2020-12-29 10:17

    Try the following:

    object.setCompletionHandler { [unowned self] (error) -> () in
        if(!error){
            weakSelf?.tableView.reloadData()
        }
        weakSelf?.progressHUD?.hide(false)
    }
    

提交回复
热议问题