从快速关闭中获取自我

时间:2015-07-06 08:53:33

标签: swift closures subclass self navigationcontroller

我正在尝试从superclass调用subclass中声明的以下方法。但是,方法self.navigationController内部变为nil超类的方法是从子类中NSURLSession任务的完成闭包调用的。

func showSuccessHUDwithMessage(msg: String) {
    dispatch_async(dispatch_get_main_queue()) {
        let successHud = MBProgressHUD(view: self.view)
        self.navigationController?.view.addSubview(successHud)

        successHud.mode = .CustomView
        successHud.customView = UIImageView(image: UIImage(named:"37x-Checkmark"))
        successHud.labelText = msg
        successHud.show(true)
        successHud.hide(true, afterDelay: 1.0)
    }
}

当我在showSuccessHUDwithMessage:中检查self的值时,我仍然会得到子类,但是无法获得navigationController

0 个答案:

没有答案