teepusink teepusink - 1 year ago 126
Objective-C Question

Check if a method exists

Is there any way I can test if a method exists in Objective-C?

I'm trying to add a guard to see if my object has the method before calling it.

Answer Source
if ([obj respondsToSelector:@selector(methodName:withEtc:)]) {
   [obj methodName:123 withEtc:456];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download