升级 Xcode 后,我的应用程序的一个关键部分停止工作。
当我的应用程序启动时,我运行一个函数来检查布尔标志并设置正确的 rootViewController。
但是我用来设置它的代码现在已经停止工作了
class func setLoginAsInitialViewContoller(window:UIWindow) {
print("SET LOGIN")
let storyboard = UIStoryboard(name: "Login", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "LoginViewController")
controller.modalPresentationStyle = .overFullScreen
window.rootViewController = controller
window.makeKeyAndVisible()
}
Run Code Online (Sandbox Code Playgroud)
特别是当应用程序获得倒数第二行时,window.rootViewController = controller它会因libc++abi.dylib: terminating with uncaught exception of type NSException错误而崩溃。
上面的函数在一个被Utilities.swift调用的类中,我正在从我的内部调用该函数AppDelegate.swift,如下所示:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var storyboard: UIStoryboard? = nil
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.isIdleTimerDisabled = true
Utilities.decideInitialViewController(window: self.window!) …Run Code Online (Sandbox Code Playgroud)