Swift UITextField deleteBackward Issue
<p>I have a series of <code>textfields</code> in a single row. Each <code>textfield</code> is limited to two characters.</p>

<p>My problem is that I want to delete all the characters and go back through all the <code>textfields</code> until I get to the first <code>textfield</code>.</p>

<p>I have subclassed the textfield and overridden the <code>deleteBackward</code> method to determine if the text in the textfield is empty. If so then change the responder to the previous textfield. </p>

<p>This is all fine, but when there is one character in the textfield and backspace is pressed, the character is deleted and the responder is changed to the previous textfield. </p>

<p>This is incorrect behaviour as I want the focus to stay on that textfield that has had its character deleted and if the delete key is pressed again, then responder should change to previous textfield. </p>

<p>I corrected this my setting a flag in the shouldChangeCharacters delegate method of the textfield. The flag is set to true if ...</p>

<pre><code>if (newLength == 0 &amp;&amp; currentLength == 0) || currentLength == 0 {
  textFieldEmpty = true
} else {
  textFieldEmpty = false
}
</code></pre>

<p>This works fine, but when the textfield is empty, and backspace is pressed, this delegate method is not called? </p>

<p>Just wandering if anyone has solved a similar problem and what approach they may have taken?</p>

<p>Thanks</p>