Skip to content

Instantly share code, notes, and snippets.

@jslegendre
Created January 13, 2018 00:26
Show Gist options
  • Save jslegendre/4e5a5994b68ea6a3fe319c85796a5fda to your computer and use it in GitHub Desktop.
Save jslegendre/4e5a5994b68ea6a3fe319c85796a5fda to your computer and use it in GitHub Desktop.
Console log all properties of a class
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