Correct (App Store Safe) way to resign a first responder?

iphone

Solution

There's actually an API to do this:

[view endEditing:YES];

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/endEditing:

Problem

What's the correct way to resign the current firstResponder? I've seen the following: Looping through fields and calling resignFirstResponder on each. ``` [[self textFieldForRow:0] resignFirstResponder]; [[self textFieldForRow:1] resignFirstResponder]; [[self textFieldForRow:2] resignFirstResponder]; [[self textFieldForRow:3] resignFirstResponder]; ``` And this which looks like it's calling a private function, is this app store safe?: ``` UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; UIView *firstResponder = [keyWindow performSelector:@selector(firstResponder)]; [firstResponder resignFirstResponder]; ``` Is there a better way? Thanks! Comments: Looks like the second method is using a private api and someone's app has been rejected because of it: link

Original source