Trying to change the root view controller after the first time running the app but it crashes.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
if(UserDefaults.standard.bool(forKey: "notFirstInApp") == false){
UserDefaults.standard.set(true, forKey: "notFirstInApp")
let state = StateTableViewController()
window?.rootViewController = state
}else{
let home = HomeViewController()
window?.rootViewController = home
}
return true
}
Crashes with
libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
Thanks in advance.