title: Handling delegate of UItextfield in UItableView
body: <p>I have a UItextfield in one of the cell in my UItable, I want few steps can be execute after return from the text field:</p>
  
  <ol>
  <li>Clear out emptyspace at beginning and the end(Trim whitespace)</li>
  <li>resign first responder (hide the keyboard)</li>
  <li>set the cell isselected</li>
  <li>append the text content of the field into a [String]</li>
  </ol>
  
  <p>But so far I only can able to execute some of it, cause the point 3 is in TableViewCell class but point 4 is in TableViewController.
  I have tried to make the UItextField outlet to both class, but it's not working
          Text_NewName.delegate = self
  Or should I access the [String] in the UITableViewCell class? but when I tried to make it as subclass, swift prompt error 'Multiple inheritance from classes'</p>
  
  <p>I do believe there must have some gap in my knowledge, makes these function to hard, please let me know if have a easier way to make it work too.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>class Namelist_ADDName_TVCell: UITableViewCell, UITextFieldDelegate {
  override func awakeFromNib() {
      super.awakeFromNib()
      Text_NewName.delegate = self
  }
  @IBOutlet weak var Text_NewName: UITextField!
  
  func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
  
      textField.text = textField.text?.trimmingCharacters(in: .whitespaces)
      textField.resignFirstResponder()
  
      if textField.text != "" {
          self.isSelected = true
          return true
      } else {
          self.isSelected = false
          return false
      }
  
  }
  </code></pre>
  
  <p>Another swift file:</p>
  
  <pre><code>class PickNameTVC: UITableViewController, UITextFieldDelegate {
  
  var selectedlist : [String]?
  
  func textFieldShouldReturn(_ theTextfield: UITextField) -&gt; Bool {
  
      if theTextfield.text != "" {
          selectedlist?.append(theTextfield.text!)
      }
      return true
  }
  }
  </code></pre>