title: How to call a function when a Modal View Controller has been dismissed
body: <p>I currently have a modal view controller that I am using to sign in. Once the sign in is completed the modal dismisses. I am having trouble getting a func to run on the original view controller once the modal is dismissed.</p>
  
  <p>I call the modal through a segue that is connected to a button on the main view controller. The func I want to run is already in viewDidLoad and viewWillAppear where it works when the view controller is originally loaded and appears. </p>
  
  <p>I am trying to figure out how to get it to run the func again once returned to the view dater the modal is dismissed.</p>
  
  <p>Original View Controller:</p>
  
  <pre><code>class SignInView: UIViewController {
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      navigationItem.hidesBackButton = true
  
  }
  
  override func viewWillAppear(_ animated: Bool) {
  
      checkUser()
  
  }
  </code></pre>
  
  <p>Modal View Controller: </p>
  
  <pre><code>@IBAction func submitBtn(_ sender: Any) {
  
      if username.text == "" &amp;&amp; password.text == "" {
          displayAlert("Error", message: "Please Enter an Username and Password")
      }
  
      if username.text == "" {
          displayAlert("Error", message: "Please Enter an Username")
      }
  
      if password.text == "" {
          displayAlert("Error", message: "Please Enter a Password")
      }
  
      self.emailLogin()
  
  }
  
  func emailLogin() {
  
      guard let username = username.text, let password = password.text else {
          return
      }
  
      Auth.auth().signIn(withEmail: username, password: password) { (user, error) in
  
          if error != nil {
              print("Login Error")
              self.displayAlert("Failed to Login", message: "Username or Password is Inccrrect")
              return
          } else {
  
          print("Successfully Signed In")
  
          self.dismiss(animated: true, completion: nil)
  
          }
  
      }
  
  }
  </code></pre>