If you recall, any data entry related activity for a UITextField is relayed via the UITextFieldDelegate. That’s how the current Done button enabling/disabling is handled too. So what you need to do is look up the documentation for UITextFieldDelegate and see if you can find a method which would handle the field contents clearing.
If you are stuck, or would rather not do the searching via documentation, then the solution appears below under the “Solution” section. But I would really encourage you to try this out on your own by looking through the documentation as I suggested - that’s the best way to grow as a developer
Solution
Add the following UITextFieldDelegate method to handle the text field clearing event and to disable the Done button:
Following your advice, I read through the documentation for the UITextFieldDelegate and found this:
The text field calls various delegate methods during editing:
. . . . .
It calls the textFieldShouldClear(_: ) method when the user taps the built-in button to clear the text.
. . . . .
Then I looked at the code for the textField(_:shouldChangeCharactersIn:replacementString:) from the book, and just below this method I tried to add following:
And after that I clicked the ‘Solution’ in your message, and found out that it’s identical!
Having this experience I’ll be more attentive to the documentation.
Thank you for your time and for advice!