title: How to enable UITableView when there is text in a textfield
body: <p>I have two <code>textFields</code> and a <code>TableView</code>. The <code>Tableview</code> should initially be disabled (meaning the <code>labels</code> greyed out and the <code>cells</code> are not clickable). When both <code>textFields</code> have values, I want the <code>TableView</code> and the <code>tableViewCells</code> to be clickable and not greyed out. 
  So far, I've added targets to both of the <code>textfields</code> to track when the user is editing:</p>
  
  <pre><code>var isUserEditing: Bool = false
  
  func setup() {
          mealItemTextField.addTarget(self, action: #selector(userIsEditing), for: UIControl.Event.editingChanged)
          priceTextField.addTarget(self, action: #selector(userIsEditing), for: UIControl.Event.editingChanged)
      }
  
  @objc func userIsEditing(sender: UITextField) {
          sender.text = sender.text?.trimmingCharacters(in: .whitespaces)
          guard
              let mealtext = mealItemTextField.text, !mealtext.isEmpty,
              let pricetext = priceTextField.text, !pricetext.isEmpty
          else
          {
              isUserEditing = false
              return
          }
          isUserEditing = true
      }
  </code></pre>
  
  <p>Then I created an extension for <code>UITableViewCell</code> that basically "enables" and "disables" the <code>tableView</code> (retrieved from <a href="https://stackoverflow.com/questions/5905608/how-do-i-make-a-uitableviewcell-appear-disabled">this</a> thread):</p>
  
  <pre><code>  extension UITableViewCell {
      func enable(on: Bool) {
          for view in contentView.subviews {
              view.isUserInteractionEnabled = on
              view.alpha = on ? 1 : 0.5
          }
      }
  }
  </code></pre>
  
  <p>Finally, I implemented this method as well as the variable <code>isUserEditing</code> in my <code>viewForHeaderInSection</code>:</p>
  
  <pre><code>func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -&gt; UIView? {
      let userModel = Data.userModels[section]
      let cell = tableView.dequeueReusableCell(withIdentifier: "nameCell") as! NameHeaderTableViewCell
      cell.setup(model: userModel)
      cell.enable(on: false)
      if isUserEditing == true {
          cell.enable(on: true)
      }
      return cell.contentView
  }
  </code></pre>
  
  <p>The <code>tableView</code> appears "disabled" when the view loads, however when I start typing in one or both of the <code>textFields</code>, it remains disabled. So obviously the <code>viewForHeaderInSection</code> isn't reloading, or being executed again. </p>
  
  <p>Is there any way to achieve this? Can I run the <code>viewForHeaderInSection</code> in realtime and update automatically? Any help is appreciated, thanks!</p>
  
  <p><a href="https://i.stack.imgur.com/JkmRP.png" rel="nofollow noreferrer">This should be the initial view when there is no text in the textField</a></p>
  
  <p><a href="https://i.stack.imgur.com/0JssQ.png" rel="nofollow noreferrer">This should be the view after there is some text in both textFields</a></p>