title: Parse Swift - Custom Login Alert View Error
body: <p>I am using the Parse framework to authenticate my user logins. They click the login button, and if there is an error an alert view pops up with the error message however since UIAlertView has been deprecated I can not get it to work with UIAlertController. </p>
  
  <p>In the viewDidAppear method I check if the user is logged in and if not, they are redirected to the login page like so: </p>
  
  <pre><code>override func viewDidAppear(animated: Bool) {
      super.viewDidAppear(animated)
      var logInController = PFLogInViewController()
  
      logInController.delegate = self
  
      var logo = UILabel()
      logo.text = "MyApp"        
      logInController.logInView?.logo = logo
  
      self.presentViewController(logInController, animated: true, completion: nil)}
  </code></pre>
  
  <p>I have a (Parse provided) function that checks proceeds if the credentials are correct else an alert is shown:</p>
  
  <pre><code>func logInViewController(logInController: PFLogInViewController, shouldBeginLogInWithUsername username: String, password: String) -&gt; Bool {
  
      if (!username.isEmpty || !password.isEmpty) {
          return true
      } else {
          let alert = UIAlertController(title: "Login Error", message: "Username or Password invalid", preferredStyle: UIAlertControllerStyle.Alert)
  
          alert.addAction(UIAlertAction(title: "Click", style: UIAlertActionStyle.Default, handler: nil))
  
          self.presentViewController(alert, animated: true, completion: nil)
  
          return false
  
      }     
  
  }
  </code></pre>
  
  <p>This generates the login view fine but when I try to change the alert for when the user enters the wrong/empty credentials I get this error: </p>
  
  <p>Warning: "Attempt to present  on  whose view is not in the window hierarchy!" </p>
  
  <p>According to the docs below I can customize the alert through that function above but, UIAlertView has been deprecated since and not sure how to proceed. </p>
  
  <p><a href="https://parse.com/tutorials/login-and-signup-views" rel="nofollow">https://parse.com/tutorials/login-and-signup-views</a> </p>
  
  <p>Anyone have an idea how to generate the error alert in the login page? </p>