Get the current first responder without using a private API

Justin Kredible picture Justin Kredible · Dec 1, 2009 · Viewed 162.7k times · Source

I submitted my app a little over a week ago and got the dreaded rejection email today. It tells me that my app cannot be accepted because I'm using a non-public API; specifically, it says,

The non-public API that is included in your application is firstResponder.

Now, the offending API call is actually a solution I found here on SO:

UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
UIView   *firstResponder = [keyWindow performSelector:@selector(firstResponder)];

How do I get the current first responder on the screen? I'm looking for a way that won't get my app rejected.

Answer

cdyson37 picture cdyson37 · May 22, 2010

If your ultimate aim is just to resign the first responder, this should work: [self.view endEditing:YES]