Created
January 26, 2014 18:30
-
-
Save kylehowells/8637147 to your computer and use it in GitHub Desktop.
If a specific class implements a method (not it's superclasses).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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