title: Error A's window is not equal to B's view's windows
body: <p>So I have a problem during performing a segue between 2 view controllers.</p>
  
  <p>Let's call the 2 view controllers</p>
  
  <p>A: LoginViewController</p>
  
  <p>B: ViewController</p>
  
  <p><a href="https://i.stack.imgur.com/ELw5f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ELw5f.jpg" alt="Image"></a></p>
  
  <p>In B I have a "Log Out" button (It is a left bar button item), when it triggers a function when it's clicked, like such, and call up dismissViewController and goes back to A.</p>
  
  <pre><code>@IBAction func logOutButton(sender: AnyObject) {
      let actionController = UIAlertController(title: "Log out", message: "Are you sure you want to log out?", preferredStyle: UIAlertControllerStyle.Alert)
  
      let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default){UIAlertAction in
          self.prefs.setInteger(0, forKey: "ISLOGGEDIN")
          self.prefs.setInteger(0, forKey: "PERMISSIONTOLOADDATA")
          self.prefs.synchronize()
  
          print("User logged out")
          socket.disconnect()
          self.dismissViewControllerAnimated(true, completion: nil)
      }
  
      let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default){UIAlertAction in
          print("Test: Log out action cancelled")
      }
  
      actionController.addAction(okAction)
      actionController.addAction(cancelAction)
      self.presentViewController(actionController, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>Nothing is wrong here, yet, but when I enter my ID in A's text field and click <strong>Login</strong> button, it triggers error like this:</p>
  
  <pre><code>2016-02-02 17:33:12.879 iCare[3852:190330] &lt;UIView: 0x7facd153cfd0; frame = (0 0; 375 667); alpha = 0.95; autoresize = W+H; tintColor = UIDeviceRGBColorSpace 1 1 1 1; layer = &lt;CALayer: 0x7facd153d140&gt;&gt;'s window is not equal to &lt;UINavigationController: 0x7facd187ae00&gt;'s view's window!
  </code></pre>
  
  <p>Login Button's code:</p>
  
  <pre><code>@IBAction func LoginButton(sender: AnyObject) {
  
      let logInUserID = loginPatientID.text
      let logInUserIDUpper = logInUserID?.uppercaseString
      if (logInUserIDUpper!.isEmpty){
          displayAlertMessage("Please enter your Patient ID!")
          return
      }else{
          print("Test: requesting login permission from database")
          loginSocket.emit("loginRequest", logInUserIDUpper!)
          print("Test: requested")
  
          loginSocket.on("loginReply") {data, ack in
              let jsonLogin = JSON(data)
              if jsonLogin[0].intValue == 1{
                  print("Test: ID Matched, putting up ViewController")
  
                  self.prefs.setObject(logInUserIDUpper, forKey: "AppUserID")
                  self.prefs.setInteger(1, forKey: "ISLOGGEDIN")
                  self.prefs.synchronize()
                  loginSocket.disconnect()
  
                  self.loginPatientID.resignFirstResponder()
                  self.performSegueWithIdentifier("gotoVC", sender: self)
              }else if jsonLogin[0].intValue == 0{
                  self.displayAlertMessage("Sorry, you are not assigned to this program")
              }else if jsonLogin[0].intValue == 3{
                  self.displayAlertMessage("Internet is not stable, please try again later")
                  print("Test: Query problem")
              }else{
                  print("Test: not getting anything from ID database")
              }
          }//socket.on
      }//else
  }//login button
  </code></pre>
  
  <p>I referred to <a href="https://stackoverflow.com/questions/25677447/error-uiviews-window-is-not-equal-to-another-views-window">This</a></p>
  
  <p>and figured that my problem is different from Mr. Paka because my log out button didn't perform a segue but rather dismiss a the view controller itself, which could in turn causes overlapping.</p>
  
  <p>Any advice?</p>