Tutorial 2 - Checklists p. 95 UIBarButtonItem

Hey,

firstly thank you for your really nice book! Secondly I am having a little problem with this UIBarButtonItem represented by the doneBarButton in the AddItemViewController. Everything is working like a charm, except of this button enabling while typing and disabling when emptying the textField. The button just does not change in any way. It just stays grey and disabled. I tried everything but no luck. So someone has any suggestion? Yes my Xcode Version is the newest (7.3.1) and my OS X Version too (10.11.5).

Thank you in advance for any help!

Are you sure the button is connected to the outlet?

Is the type of the button set to Done? (Note there are two attributes to change here and they both must be set to Done.)

I checked it once again in the Connections Inspector and yes, the Button is connected to its Outlet “doneBarButton” and also is connected to the Send Action done() of the AdItemViewController. With “type of the Button set to done” you mean the two fields “Style” and “System Item” in the Attributes Inspector right? If correct, they are both set to “Done”. So unfortunately it has to be some different mistake.

Check to make sure you’ve set the delegate of your text field.
Without that, the textField:shouldChangeCharactersInRange:replacementString:method which enables/disables the Done button will not get called.

I checked it and the text field has the connection to the delegate in the Connections inspector. Any other suggestions?

If you zip up the project folder and upload it somewhere, I can take a quick look.

Thank you for your offer! I uploaded the zipped Project Folder to my dropbox: Dropbox - Checklists.zip - Simplify your life

In the UITextFieldDelegate method, make sure the spelling is correct. :slight_smile:

shouldChangeCharatersInRange

Something’s missing there. :wink:

Shame on me for that newbie mistake :see_no_evil: It’s always the spelling! :smiley: Thank you again for your research! Next time I will triple check instead of double check!