title: Execute a function from other view controller
body: <p>I have the following interfaces:</p>
  
  <p><a href="https://i.stack.imgur.com/XAQSJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XAQSJ.png" alt="enter image description here"></a></p>
  
  <p>In the table view I set the new values for the user and I would like to call the function to update the data from the server when the button "Done" from the main view is pressed. </p>
  
  <p>How I can do it?</p>
  
  <p>I have tried: </p>
  
  <pre><code>@IBAction func doneTapped(_ sender: Any){
      ProfileEditingTableViewController().updateData()
  }
  </code></pre>
  
  <p>But all the text fields from the other view are null because it seems to be a new instance of ProfileEditingTableViewController.<br>
  updateData() can't be static. </p>
  
  <pre><code>class ProfileEditingViewController: UIViewController {
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
      }
  
      @IBAction func cancelButton(_ sender: Any) {
          dismiss(animated: true, completion: nil)
      }
  
      @IBAction func doneTapped(_ sender: Any) {
          // Here I have to save the data from the other View
          dismiss(animated: true, completion: nil)
      }
  
  }
  
  class ProfileEditingTableViewController: UITableViewController {
  
   func updateData() {
   ... 
   }
  }
  </code></pre>