title: Call function from other ViewController
body: <p>I have two ViewControllers, <code>FirstViewController</code> and <code>SecondViewController</code>. Both have an own Swift file, <code>FirstViewController.swift</code> and <code>SecondViewController.swift</code>. </p>
  
  <p><code>FirstViewController.swift</code> contains:</p>
  
  <pre><code>class FirstViewController: UIViewController {
      @IBAction func callFunctionInOtherClass(sender: AnyObject) {
  //        Call "func showAlert" in SecondViewController when clicking the UIButton in FirstViewController
      }
  }
  </code></pre>
  
  <p><code>SecondViewController.swift</code> contains:</p>
  
  <pre><code>class SecondViewController: UIViewController {
  
      @IBOutlet weak var textField: UITextField!
  
      func showAlert(sender: AnyObject) {
          let alert = UIAlertView(title: "Working!", message: "This function was called from FirstViewController!\nTextField says: \(textField.text!)", delegate: nil, cancelButtonTitle: "Okay")
          alert.show()
      }
  }
  </code></pre>
  
  <p>I want to be able to call the <code>func showAlert()</code> in <code>SecondViewController</code> when taping on the <code>UIButton</code> in <code>FirstViewController</code>.</p>
  
  <p>I've already spent many nights to find a solution but none worked. Does anybody know what to do to reach this goal?</p>
  
  <p>I uploaded a sample Xcode project here: <a href="http://www.filedropper.com/callfuntioninotherclassx" rel="nofollow">CallFuntionInOtherClassX | filedropper.com</a></p>
  
  <p><em>P.S.: Of course, I could post some code and explain what error I get, but I think it's not reasonable because I really don't know how to do that.</em></p>