Skip to content

Instantly share code, notes, and snippets.

@Koze
Created April 4, 2015 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Koze/f7595b64941f89ea8799 to your computer and use it in GitHub Desktop.
Save Koze/f7595b64941f89ea8799 to your computer and use it in GitHub Desktop.
Print Method List, Property List, and Ivar List
#import <objc/runtime.h>
void PrintMethodList(Class cls) {
printf("// Method List of %s\n", class_getName(cls));
unsigned int outCount;
Method *methodList = class_copyMethodList(cls, &outCount);
for (unsigned int i=0; i<outCount; i++) {
Method m = methodList[i];
SEL sel = method_getName(m);
printf("%s\n", sel_getName(sel));
}
free(methodList);
}
void PrintPropertyList(Class cls) {
printf("// Property List of %s\n", class_getName(cls));
unsigned int outCount;
objc_property_t *propertyList = class_copyPropertyList(cls, &outCount);
for (unsigned int i=0; i<outCount; i++) {
objc_property_t property = propertyList[i];
printf("%s\n", property_getName(property));
}
free(propertyList);
}
void PrintIvarList(Class cls) {
printf("// Ivar List of %s\n", class_getName(cls));
unsigned int outCount;
Ivar *ivarList = class_copyIvarList(cls, &outCount);
for (unsigned int i=0; i<outCount; i++) {
Ivar v = ivarList[i];
printf("%s\n", ivar_getName(v));
}
free(ivarList);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment