title: Why is my Swift code function only running once?
body: <p>So I'm new to programming and I'm working on a Swift tax calculator learning exercise. At the moment, I'm just trying to set up a few things before I start plugging the calculations in.</p>
  
  <p>I'm trying to get the code to take a text input, interpolate it into a string and print that in a text view.</p>
  
  <p>So far, my code works once, but from then on it seems to stop working. I essentially just want my code to reset itself when the user clicks inside the first input text field.</p>
  
  <p>I've tried setting the text view to "", but that doesn't seem to work. It just interpolates "", which is not what I want.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>class ViewController: UIViewController {
  
      @IBOutlet weak var income: UITextField!
  
      @IBOutlet weak var takeHomePay: UITextView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          income.delegate = self
          // Do any additional setup after loading the view.
  
      }
  
      @IBAction func calculateTapped(_ sender: Any) {
          if takeHomePay.text.isEmpty {
          takeHomePay.text = "You are earning $\(income.text!)"
          } else if !takeHomePay.text.isEmpty {
              takeHomePay.text = "You need to enter a figure"
          } else {
              takeHomePay.text = "ERROR"
          }
  
      }
  
      override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
          income.resignFirstResponder()
      }
  
  }
  
  extension ViewController : UITextFieldDelegate {
      func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
          textField.resignFirstResponder()
          return true
      }
  
  }
  </code></pre>
  
  <p>Why is my function only running once? I want to see the output change every time I change the input. Probably a simple fix, but as I say, I am only learning.</p>
  
  <p>Help would be much appreciated!</p>