title: Format currency in textfield in Swift on input
body: <p>I am trying to format currency input in a textfield in Swift as the user inputs it.</p>
  
  <p>So far, I can only format it successfully when the user finishes inputting:</p>
  
  <pre><code>@IBAction func editingEnded(sender: AnyObject) {
  
      let formatter = NSNumberFormatter()
      formatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
      formatter.locale = NSLocale(localeIdentifier: "en_US")
      var numberFromField = NSString(string: textField.text).doubleValue
  
      textField.text = formatter.stringFromNumber(numberFromField)
  }
  </code></pre>
  
  <p>However, I would like for the currency to be formatted the moment the user inputs it. When I try to do it on the TextField actions "Editing Changed" or "Value Changed", I can only enter 1 number (if I enter 8, it becomes $8.00) but then once I enter a second number everything goes to $0.00 and I cannot enter further beyond that.</p>
  
  <p>Any suggestions? I feel like this should be an easy fix but I can't quite get at it.</p>