title: Change root ViewController programmatically
body: <p>I'm trying to change root ViewController of my app programmatically. Once user registers I want different root ViewController. This is my code</p>
  
  <pre><code>let storyboard = UIStoryboard(name: "Main", bundle: nil)
  let vc = storyboard.instantiateViewController(withIdentifier: "tabBarVC")
  
  UIApplication.shared.keyWindow?.rootViewController = vc
  UIApplication.shared.keyWindow?.makeKeyAndVisible()
  
  self.present(vc, animated: true, completion: nil)
  </code></pre>
  
  <p>After <code>vc</code> is presented I kill the app, and when I run it again the root ViewControler is the same. What am I doing wrong? I also tried the same code in AppDelegate, but no success.</p>