Created
January 13, 2018 00:26
-
-
Save jslegendre/4e5a5994b68ea6a3fe319c85796a5fda to your computer and use it in GitHub Desktop.
Console log all properties 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_printProperties(Class cl) { | |
unsigned int propCount; | |
objc_property_t *props = class_copyPropertyList(cl, &propCount); | |
printf("Properties for %s: \n", class_getName(cl)); | |
for (int i = 0; i < propCount; i++) { | |
objc_property_t prop = props[i]; | |
printf("%s : %s \n", | |
property_getName(prop), | |
property_getAttributes(prop)); | |
} | |
free(props); | |
} | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
Class bundle = objc_getClass("NSBundle"); | |
class_printProperties(bundle); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment