func presentLoggedInScreen() {
let stroyboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let logginedInVCViewController:LogginedInVCViewController = storyboard.instantiateViewController(withIdentifier: "LogginedInVCViewController" as! LogginedInVCViewController,
self.present(logginedInVCViewController, animated: true, completion: nil))
}
如何避免此错误?
在其自己的初始值
中使用的变量
答案 0 :(得分:3)
试试这个:
func presentLoggedInScreen() {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if let logginedInVCViewController = storyboard.instantiateViewController(withIdentifier: "LogginedInVCViewController") as? LogginedInVCViewController {
self.present(logginedInVCViewController, animated: true, completion: nil)
}
}
编辑:
使用可选的绑定和导致错误的是,和额外的)
有时XCode的intellisense无法正常工作,所以首先尝试分析问题:)