This code is in the AppDelegate. Xcode doesn't throw any errors, but this code doesn't work when I recall the func in other View Controller buttons. ( Either make the app open on View Controller VC1 or VC2 ) The recall code: (UIApplication.shared.delegate as! AppDelegate).configureInitialViewController()
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
configureInitialViewController()
return true
}
**// determins which VC will be initially launched.**
func configureInitialViewController() {
var initialVC: UIViewController
let storyboard = UIStoryboard(name: "Main", bundle: nil)
if 1 > 0 {
initialVC = storyboard.instantiateViewController(withIdentifier: VC1)
} else {
initialVC = storyboard.instantiateViewController(identifier: VC2)
}
window?.rootViewController = initialVC
window?.makeKeyAndVisible()
}