title: Choose which view to load when app runs in Swift
body: <p>I would like to know which is the best way to do this and how to implement it:
  When the app runs, it checks if there's a value in user defaults 
  <code>NSUserDefaults.standardUserDefaults().valueForKey("uid") == nil</code> If the value is nil, I would like the app to redirect to a view called <code>LoginViewController</code>, and if not nil, go to <code>MainViewController</code>. Both clases are <code>UIViewController</code>.
  I was thinking in create a new <code>RedirectViewController</code> as initial View Controller, and check it there, but it doesn't work, it doesn't redirects:</p>
  
  <pre><code>class RedirectOnStart: UIViewController {
  
    override func viewDidLoad() {
  
      super.viewDidLoad()
      if NSUserDefaults.standardUserDefaults().valueForKey("uid") == nil {
          self.performSegueWithIdentifier("loginRegisterSegue", sender: nil)
  
      } else {
          self.performSegueWithIdentifier("mainViewSegue", sender: nil)
      }
    }
  
  
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
  
      if segue.identifier == "loginRegisterSegue" {
  
          let nav = segue.destinationViewController as! LoginRegisterViewController
      }
  
      if segue.identifier == "mainViewSegue" {
  
          let nav = segue.destinationViewController as! ViewController
  
      }
  
    }
  }
  </code></pre>