title: Segue from bar button item in navigation bar to another view controller won't run my code?
body: <p>I'm having problems with my segues in my app.</p>
  
  <p>I added a bar button item to my navigation bar and ctrl dragged it to another view controller which works as expected when tested.  I ctrl dragged it again this time making it an Action in its own VC and added code.</p>
  
  <p>What I want to happen when it is pressed as well as performing the segue but only the segue happens. If I delete the segue then the code runs but I can't get both to work together like I was expecting.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>import UIKit
  import CoreData
  
  class NewClientViewController: UIViewController, UITextFieldDelegate {
  
      var managedObjectContext: NSManagedObjectContext!
  
      @IBOutlet weak var nameTextField: UITextField!
      @IBOutlet weak var ageTextField: UITextField!
      @IBOutlet weak var telephoneTextField: UITextField!
      @IBOutlet weak var emailTextField: UITextField!
      @IBOutlet weak var heightTextField: UITextField!
      @IBOutlet weak var weightTextField: UITextField!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          managedObjectContext = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
      }
  
      // Dismiss keyboard when empty space tapped
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          nameTextField.endEditing(true)
          ageTextField.endEditing(true)
          telephoneTextField.endEditing(true)
          emailTextField.endEditing(true)
          heightTextField.endEditing(true)
          weightTextField.endEditing(true)
      }
  
      // Dismiss keyboard when return tapped
      func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
  
          textField.resignFirstResponder()
  
          return true
      }
  
      @IBAction func saveButton(_ sender: Any) {
  
          let clientItem = Client(context: managedObjectContext)
  
          clientItem.name = nameTextField.text
          clientItem.age = ageTextField.text
          clientItem.telephone = telephoneTextField.text
          clientItem.email = emailTextField.text
          clientItem.height = heightTextField.text
          clientItem.weight = weightTextField.text
  
          do
          {
              try self.managedObjectContext.save()
              print("Successfully Saved!")
          }
          catch
          {
              print("Could not save data \(error.localizedDescription)")
          }
  
      }
  
  }
  </code></pre>