title: How to determine which textfield is active swift
body: <p>I cant figure out which <code>UITextField</code> is currently active so i can clear its text if they hit cancel on a <code>UIBarButtonItem</code>. Here is my code. There is a view with a <code>UIPickerView</code>,<code>UIToolBar</code> and two bar button items. The cancel item has an action that will clear its text only i cant figure out how to get the correct <code>UITextField</code>.</p>
  
  <p>I've tried these both:</p>
  
  <pre><code>@IBAction func cancelText(sender: AnyObject) {
  
  
      if self.truckYear.editing == true{
  
          println("truckYear")
  
          clearText(self.truckYear)
      } else if self.truckMake.editing == true{
  
          clearText(self.truckMake)
      }
  }
  @IBAction func doneText(sender: AnyObject) {
  
      pickerView.hidden = true
  }
  
  
  func clearText(textField:UITextField){
  
      println("in clear text")
  
      textField.text = nil
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>@IBAction func cancelText(sender: AnyObject) {
  
  
      if self.truckYear.isFirstResponder(){
  
          println("truckYear")
  
          clearText(self.truckYear)
      } else if self.truckMake.isFirstResponder(){
  
          clearText(self.truckMake)
      }
  }
  @IBAction func doneText(sender: AnyObject) {
  
      pickerView.hidden = true
  }
  
  
  func clearText(textField:UITextField){
  
      println("in clear text")
  
      textField.text = nil
  }
  </code></pre>