我只是尝试 XCode 6.3 beta 和 Swift 1.2
这里的as!
是什么意思?
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == signUpViewId {
var signUpView = segue.destinationViewController as! SignUpViewController
}
}
最佳答案
这意味着,如果segue.destinationViewController
是一个SignUpViewController
,它会将其转换为SignUpViewController
,否则它将产生一个运行时错误。
但如果您使用 as?
,在这种情况下,如果 segue.destinationViewController
是 NOT 一个 SignUpViewController
,那么它将是只是零,没有运行时错误。
关于swift - 作为的意思!在 Swift 1.2 - Xcode 6.3 beta 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28454961/