I'm trying to set up an instruction-like page showing when the app is first downloaded or re-downloaded. I want instructionIntro to show on first launch, and Main to appear the rest of the time. This code is in my GuideBookIntroClass. Can anyone provide a better solution or what the issue in my code is? It's still showing my old intro page into Main.storyboard.
let isFirstLaunch = UserDefaults.standard.value(forKey: "isFirstLaunch") as? Bool
if isFirstLaunch == true {
//It's the initial launch of application.
let storyBoard : UIStoryboard = UIStoryboard(name: "instructionIntro", bundle:nil)
let mainViewController = storyBoard.instantiateViewController(withIdentifier: "instructionIntro") as! InstructionIntroViewController
let navigationController = UINavigationController(rootViewController: mainViewController)
if let window = UIApplication.shared.delegate?.window {
window?.rootViewController = navigationController
}
}
else {
// not initial launch
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let mainViewController = storyBoard.instantiateViewController(withIdentifier: "Main") as! GuideBookIntroClass
let navigationController = UINavigationController(rootViewController: mainViewController)
if let window = UIApplication.shared.delegate?.window {
window?.rootViewController = navigationController
}
}