【发布时间】:2015-07-15 22:33:57
【问题描述】:
我在 XCTest 设置中有此代码
var passcodeVC:HNPasscodeViewController!
override func setUp() {
super.setUp()
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle(forClass: self.dynamicType))
self.passcodeVC = storyboard.instantiateViewControllerWithIdentifier("HNPasscodeViewController") as! HNPasscodeViewController
self.passcodeVC.viewDidLoad()
}
Xcode 在这一行给我错误“Could not cast value of type”
self.passcodeVC = storyboard.instantiateViewControllerWithIdentifier("HNPasscodeViewController") as! HNPasscodeViewController
我正在使用带有 Xcode 7 beta 3 的 Swift 2.0。我尝试了捆绑:
nil
NSBundle.mainBundle()
NSBundle(forClass: self.classForCoder)
NSBundle(forClass: self.dynamicType) (Xcode doesn't autocomplete this but gives me no error)
我还添加了自定义视图控制器类来编译列表和主故事板到测试目标的资源。
有什么想法吗?谢谢
【问题讨论】:
标签: ios objective-c swift uistoryboard xctest