I have finished the chapter. as a result the button Done becomes disabled each time I press the Clear button but only for the first three times. When I push Clear button for the forth time, the textField stays empty and the Done is enabled.
After entering one text and pushing Done, and then clearing 4 times and pushing Done again, my print message in the console looks like that:
Contents of the text field: Nbn
Contents of the text field:
Any advice would be appreciated.
One thing you can do is check your project against the provided final project in the book if you want to troubleshoot the issue yourself.
Alternatively, please upload your project as a ZIP file somewhere and provide a link to the ZIP file so that I (or someone else) can download the file and see what might be going on.
I have downloaded the final version of 12-Add-item-screen and ran it on the simulator. The problem still exists.
When does it happen?
After filling the textField and then clearing with clear button, after 3,4 repetitions the bar button ādoneā becomes enabled even though the textField is empty.
My first instinct is that this might be a timing issue where tapping the clear button (or entering text) rapidly results in the state for the app being set incorrectly - basically, the app thinks the text field is not empty even though it is. I would have to actually check this out with the final project to see if I can replicate it.
Alternatively, you can test the theory out yourself by doing things slowly enter some text, wait a second, hit clear, wait a second, enter text again, wait a second, hit clear, wait a second etc. Does the issue still occur? Or is it gone when thereās a bit of a delay between entering text and tapping clear?
I have added multiple print() functions, to see what string exactly gets into the textField and found out that when I click the Clear button the String disappears (visually) but the print function prints some String. It turns out that this String is a āCorrectionā that was offered to me instead of the String that I typed in.
The temporary solution that I found is to turn off the ācorrectionā feature in the textField attribute inspector under Text Input Traits .