title: Swift - Xcode 6 opening signup view from app delegate doesn't work
body: <p>I want when I open my app, if a certain condition is true, the app to open to a custom SignUpViewController instead of my TabBarViewController.</p>
  
  <p>What I did is in the application function in my app delegate is use the following code:</p>
  
  <pre><code>func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
          //removed condition for testing
          var rootViewController = self.window!.rootViewController
          let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
          var profileViewController: SignUpViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Registration") as SignUpViewController
  
          rootViewController?.navigationController?.popToViewController(profileViewController, animated: true) 
  
          return true
  
  }
  </code></pre>
  
  <p>I have named my ViewController in the storyboard and everything should work fine. but instead of opening to the SingUpViewController the app opens normally to the first tab in my TabBarViewController.</p>
  
  <p>I don't get any crashes it just doesn't show.</p>
  
  <p>Using: pushViewController didn't work either.</p>
  
  <p>My storyboard:</p>
  
  <p><img src="https://i.stack.imgur.com/e9BH7.png" alt="enter image description here"></p>
  
  <p>Does anyone know what could be the cause of this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is what I write to present the view instead of using nav controller:</p>
  
  <p>I switch out this line:</p>
  
  <pre><code>rootViewController?.navigationController?.popToViewController(profileViewController, animated: true) 
  </code></pre>
  
  <p>With this line:</p>
  
  <pre><code>rootViewController?.presentViewController(profileViewController, animated: true, completion: nil)
  </code></pre>
  
  <p>When I run it, i get a crash on this line:</p>
  
  <p>class AppDelegate: UIResponder, UIApplicationDelegate {</p>
  
  <p>Here is an image of the crash:</p>
  
  <p><img src="https://i.stack.imgur.com/rzyi5.png" alt="enter image description here"></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Sorry, I am new to Xcode and Swift and iPhone development, here is the console when it crashes:</p>
  
  <p><img src="https://i.stack.imgur.com/vR850.png" alt="enter image description here"></p>
  
  <p>From what I can see now it refers to a loginButton from the viewController I am trying to present. I am guessing there is a problem there, ill try and fix it, but if you know what the problem is answer anyways.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I can see the problem lies somewhere in the new ViewController. Yet it is referring to something which does not exist.</p>
  
  <p>Here is the code of the new view controller:</p>
  
  <pre><code>import UIKit
  
  class SignUpViewController: UIViewController {
  
      let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
  
      @IBOutlet weak var usernameField: UITextField!
      @IBOutlet weak var passwordField: UITextField!
      @IBOutlet weak var emailField: UITextField!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
      }
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
      @IBAction func signUpPressed(sender: AnyObject) {
  
      }
  
      @IBAction func loginPressed(sender: AnyObject) {
  
      }
  
  }
  </code></pre>