Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Derek Medlin
6,151 PointsendEditing: vs resignFirstResponder
I tend to just call
[self.view endEditing:YES];
instead of
[textField resignFirstResponder];
Just because it's easy and I can do it anywhere without having to do anything else, is there a down side to this? Is there anything wrong with just calling endEditing: when you want to hide the keyboard? I haven't noticed any problems with this, I just like to do the "right" way of doing things even if there isn't a noticeable side effect. Basically, is there a reason to call resignFirstResponder over endEditing:. If anyone just can shed some light on this it would be very appreciated. Thanks.
2 Answers
Stone Preston
42,016 Pointshmm from what ive found on google I cant find anything that suggests this is bad practice. But that doesnt necessarily mean it isnt bad practice. It sure is easier than having to deal with the text field delegate methods, especially when using multiple text fields
Derek Medlin
6,151 PointsThanks for the reply! I searched google as well and I never can find anything against it. I'm always paranoid that if I do something in a way that I haven't either learned from here or in a programming book, that it's bad practice so i'm constantly googling stuff haha. Thanks again and I appreciate you being on here answering so many peoples questions!