Skip to content

Instantly share code, notes, and snippets.

@kylehowells
Created January 26, 2014 18:30
Show Gist options
  • Save kylehowells/8637147 to your computer and use it in GitHub Desktop.
Save kylehowells/8637147 to your computer and use it in GitHub Desktop.
If a specific class implements a method (not it's superclasses).
BOOL KH_ClassImplementsSelector(Class aClass, SEL aSelector){
Method *methods;
unsigned int count;
unsigned int i;
methods = class_copyMethodList(aClass, &count);
BOOL implementsSelector = NO;
for (i = 0; i < count; i++) {
if (sel_isEqual(method_getName(methods[i]), aSelector)) {
implementsSelector = YES;
break;
}
}
free(methods);
return implementsSelector;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment