I have two VC (ViewController, SettingsVC, VC2).
How can I make it so that when you turn on the Switch
Write this code in didFinishLaunchingWithOptions
-
let isSwitchOn = UserDefaults.standard.bool(forKey: "isSwitchOn")
if isSwitchOn {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc2 = storyboard.instantiateViewController(withIdentifier: "Your identifier")
self.window!.rootViewController = vc2;
}
Set isSwitchOn
in SettingsVC
like this -
UserDefaults.standard.set(true, forKey: "isSwitchOn")