title: What is the correct way to do a login screen in swift
body: <p>I'm currently developing an iOS app with swift. And I need to make a Login screen.<br>
  What I want to do is: the first time the user opens the app, the login screen will be shown, but once the user is logged in (I know it because I save the server's session token in <code>NSUserDefaults</code> when the user logs in) the app will launch the main screen directly.<br>
  I'm wondering what is the correct way to achieve this (telling the app which screen to show). I tries 2 ways:  </p>
  
  <ol>
  <li>Loading the app at main screen, and if there is no token yet, present the <code>LoginViewController</code>. The problem I had with this way is that when I run the app it says that <code>LoginViewController</code>is not in the window hierarchy.</li>
  <li>In the <code>AppDelegate</code> I check if there is a token and depending on the result I make <code>LoginViewController</code> or <code>MainViewController</code> the <code>rootViewController</code>. The problem with this is that it takes too long to change the <code>rootViewController</code> when changing it from <code>LoginViewController</code> to <code>MainViewController</code>.</li>
  </ol>
  
  <p>Is there any better way to achieve this? which one is the best? Thank you guys.</p>