我刚刚升级到 Xcode 9.0 Beta,现在我的应用程序在启动时崩溃了。
2017-06-09 14:35:18.817213-0700 recharge-consumer-ios[13524:1720597] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[recharge_consumer_ios.SignedOutContainerViewController<0x105c691b8> init]: cannot init a class object.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010caf4f6b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ba3e121 objc_exception_throw + 48
2 CoreFoundation 0x000000010cb7f6ff +[NSObject(NSObject) init] + 127
3 recharge-consumer-ios 0x0000000105322223 _T021recharge_consumer_ios22RechargeViewControllerCACycfCTD + 19
失败的调用是(简化的):
func setAndRefreshChildViewControllersWithTypes(_ types: [MyViewControllerProtocol.Type]) {
for type in types {
let controller = type.init() as! UIViewController // This is what crashes
}
...
}
在哪里MyViewControllerProtocol
:
protocol MyViewControllerProtocol {
// some other fields here too
init()
}
失败的实例如下所示:
class SignedOutContainerViewController: MyViewController {
required init() {
super.init(nibName: "SignedOutContainerViewController")
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
哪里MyViewController
是:
class MyViewController: UIViewController, MyViewControllerProtocol {
required init() {
fatalError("init has not been implemented")
}
init(nibName nibNameOrNil: String?) {
super.init(nibName: nibNameOrNil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
知道出了什么问题,或者还有其他地方可以看的指示吗?Xcode 9.0 测试版 (9M136h),快速 3。