So iOS 13 is really causing trouble for me! I cant get my head around how the SceneDelegate can be uses within my existing application.
Currently I'm using a boolean check in my AppDelegate
to determine which ViewController is presented first.. I need to figure out how to replicate this using the SceneDelegate
.
My main concern is how can I ensure my app will work on both iOS 13 and any iOS version before? If I add the SceneDelegate won't it crash my app running on pre iOS 13?
Here is my current method of setting the rootVC
if (loggedIn == nil){
Utilities.setLoginAsInitialViewContoller(window: window)
}
else
{
if(termsAgree == nil){
Utilities.setTermsAsInitialViewController(window: window)
}
if(loggedIn != nil){
if(termsAgree != nil){
Utilities.setHomeAsInitialViewContoller(window: window)
}
}
}
class func setLoginAsInitialViewContoller(window:UIWindow) {
let storyboard = UIStoryboard(name: “Login”, bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: “LoginViewController”)
window.rootViewController = controller
window.makeKeyAndVisible()
}
class func setHomeAsInitialViewContoller(window:UIWindow) {
let storyboard = UIStoryboard(name: “Home”, bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: “MainViewNavController”)
window.rootViewController = controller
window.makeKeyAndVisible()
}
class func setTermsAsInitialViewController(window:UIWindow){
let storyboard = UIStoryboard(name: “Terms”, bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: “TermsViewController”)
window.rootViewController = controller
window.makeKeyAndVisible()
}
The above code is contained in my Utilities.swift
class and is called in my AppDelegate.swift
like this:
Utilities.decideInitialViewController(window: self.window!)