Created
January 13, 2018 00:27
-
-
Save jslegendre/b9b601fc19735c431d02449fd066ad90 to your computer and use it in GitHub Desktop.
Print all methods of a class
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
void class_printMethods(Class cl) { | |
unsigned int methodCount = 0; | |
Method *methods = class_copyMethodList(cl, &methodCount); | |
printf("Methods for %s: \n", class_getName(cl)); | |
for (int i = 0; i < methodCount; i++) { | |
Method method = methods[i]; | |
printf("%s : %s \n", | |
sel_getName(method_getName(method)), | |
method_getTypeEncoding(method)); | |
} | |
free(methods); | |
} | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
Class bundle = objc_getClass("NSBundle"); | |
class_printMethods(bundle); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment