title: Space between characters in UITextField
body: <p>How can I add space between characters? (hundred, thousand, million)
  For example</p>
  <blockquote>
  <p>550<br>
  5 500<br>
  55 500<br>
  555 500<br>
  5 555 000 etc.</p>
  </blockquote>
  <p>I did this</p>
  <pre><code>@IBAction func textEditingChanged(_ sender: UITextField) {
      if sender.text!.count &gt; 0 &amp;&amp; sender.text!.count % 4 == 0 &amp;&amp; sender.text!.last! != &quot; &quot; {
         sender.text!.insert(&quot; &quot;, at:sender.text!.index(sender.text!.startIndex, offsetBy: sender.text!.count-3) )
      }
  }
  </code></pre>
  <p>but it doesn't work properly</p>
  <blockquote>
  <p>5 000<br>
  5 00000<br></p>
  </blockquote>
  <p>then deleting with new spaces</p>
  <blockquote>
  <p>5 000...0<br></p>
  </blockquote>