title: Trying to format a UITextField to behave like a currency calculator for only numeric input in iOS
body: <p>I have a <code>UITextField</code> in my application that is supposed to receive only numeric input from the user.  This numeric input is supposed to represent currency (i.e. have only two decimal places), have the default value of <strong>0.00</strong> when nothing has been entered.  I also would like to have a <strong>"$"</strong> sign that is on the far left, with the number right aligned, such that the number moves from right to left like such:</p>
  
  <p>e.g. when entering the number <strong>"1234.56"</strong>.</p>
  
  <p><strong>1. $     0.00</strong>.</p>
  
  <p><strong>2. $     0.01</strong>.</p>
  
  <p><strong>3. $     0.12</strong>.</p>
  
  <p><strong>4. $     1.23</strong>.</p>
  
  <p><strong>5. $    12.34</strong>.</p>
  
  <p><strong>6. $   123.45</strong>.</p>
  
  <p><strong>7. $ 1,234.56</strong>.</p>
  
  <p><strong>8. and so on...</strong></p>
  
  <p>I have the <code>UITextField</code> right aligned so that it already moves the numbers over to the left from the right.  However, I need to place the <strong>"$"</strong> inside the <strong>UITextField</strong>, and I would like the default <strong>0.00</strong> value to be modified to the number entered by the user one digit at a time.  The user should NOT have to enter the decimal point, as it should already be in the textfield holding its position.  I then would like the number to have a <strong>","</strong> to be automatically entered to separate every three digits.  I would like the application to do this <strong>AS THE USER IS ENTERING THE NUMBERS</strong>, and not formatted afterwards when everything is entered.  How would I do this?  I have seen a lot of people say that I am to use <code>NSNumberFormatter</code>, but I want to know how do I use it in conjunction with the <code>UITextField</code> such that it formats the numeric text on the fly, as described above?</p>
  
  <p>I have found the following question posted on StackOverflow some time ago:</p>
  
  <p><a href="https://stackoverflow.com/questions/276382/what-is-the-best-way-to-enter-numeric-values-with-decimal-points">What is the best way to enter numeric values with decimal points?</a></p>
  
  <p>but I want to know how to actually incorporate it as a solution to my problem.</p>