Checklists Chapter 12, textField delegate method done button fix

I was running into an issue where the textField method was not correctly acting as a delegate and was therefore not recognizing my input into the text field. Consequently, the “Done” button was not enabling/disabling properly in response.

Adding the line “textField.delegate = self” to the bottom of the viewDidLoad method fixed the issue. (see: ios - UITextFieldDelegate method not called - Stack Overflow )

Anyway, I figured I would post the fix, since I didn’t see anyone else asking questions about it, and in case anyone else wants to weigh in on why I encountered this problem, or if my solution is not a good one. Thanks!

In Chapter 12 page 279, the book instructs you to set up the text field’s delegate via the storyboard. Did you do that? If you did, you generally do not need to set the delegate via code as you did.

Of course, you can always set the delegate via code instead of the storyboard too. Neither method is “more correct” than the other - it’s just a matter of different ways to do the same thing :slight_smile:

Hey Fahim,

I did set up the delegate via the storyboard as instructed on page 279. I found that step to be necessary but not sufficient.

It did set up the text field as a delegate elsewhere in the code, but for some reason it did not connect the text field to the textField method, so my fix was still necessary to get things working.



This topic was automatically closed after 166 days. New replies are no longer allowed.