Created
April 4, 2015 15:46
-
-
Save Koze/f7595b64941f89ea8799 to your computer and use it in GitHub Desktop.
Print Method List, Property List, and Ivar List
This file contains hidden or 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
#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