title: Capturing a TextView value within a TableViewCell, when a button in another TableViewCell is pressed before segueing?
body: <p>I have the following tableView:</p>
  
  <p><a href="https://i.stack.imgur.com/DiLHs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DiLHs.png" alt="enter image description here"></a></p>
  
  <p>When the user clicks the blue Pay Cash/Card button, they segue to another tableView. </p>
  
  <p>The problem I have is; when the user clicks the button, the value of the textView doesn't get captured within the delegate method. For example, I have implemented the 'TextView' protocol and implemented the following functions from the TextView class:</p>
  
  <pre><code>func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -&gt; Bool {
      if(text == "\n") {
          textView.resignFirstResponder()
          return false
      }
      return true
  }
  
  func textViewDidBeginEditing(_ textView: UITextView) {
      if textView.textColor == UIColor.lightGray {
          textView.text = nil
          textView.textColor = UIColor.black
      }
  }
  
  func textViewDidEndEditing(_ textView: UITextView) {
      if textView.text.isEmpty {
          textView.text = "Enter a note for the takeaway (optional)"
          textView.textColor = UIColor.lightGray
      } else {
          self.note = textView.text
      }
  }
  </code></pre>
  
  <p>As you can see, if I enter some text, and then click the Done button, before clicking the segue button, I'm able to pass the value successfully. However, if the user clicks the blue segue button before clicking done, it segues and I'm unsure how to capture the value of the textView. The code for my button delegate is below, and I've also passed my prepareForSegue method.</p>
  
  <p>I hope what I'm trying to achieve makes sense; I do struggle explaining things, so please let me know if I'm unclear and I'll try expand further. </p>
  
  <p>Thanks,
  J</p>
  
  <pre><code>func buttonPressed() {
      performSegue(withIdentifier: "showNameAddress", sender: nil)
  }
  
  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      if(segue.identifier == "showNameAddress") {
          let nameAddressTableViewController = segue.destination as! NameAddressTableViewController
          if(self.delivery == true) {
              nameAddressTableViewController.delivery = true
              nameAddressTableViewController.finalPrice = self.basket.totalPriceOfAllItems() + Double(BasketArrays.deliveryCharge)!
          } else {
              nameAddressTableViewController.delivery = false
              nameAddressTableViewController.finalPrice = self.basket.totalPriceOfAllItems()
          }
          nameAddressTableViewController.note = self.note
          nameAddressTableViewController.show(self, sender: nil)
      }
  }
  </code></pre>