Skip to content

Instantly share code, notes, and snippets.

@jslegendre
Created January 13, 2018 00:27
Show Gist options
  • Save jslegendre/b9b601fc19735c431d02449fd066ad90 to your computer and use it in GitHub Desktop.
Save jslegendre/b9b601fc19735c431d02449fd066ad90 to your computer and use it in GitHub Desktop.
Print all methods of a class
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