Last active
August 29, 2015 14:17
-
-
Save rraallvv/9dd77741344266d95a26 to your computer and use it in GitHub Desktop.
Obj-C introspection
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
static void printIvarsList(Class classType) { | |
printf("\n"); | |
do { | |
unsigned int count = 0; | |
Ivar* ivars = class_copyIvarList(classType, &count); | |
for(unsigned int i = 0; i < count; ++i) { | |
printf("%s::%s %s\n", [classType description].UTF8String, ivar_getName(ivars[i]), ivar_getTypeEncoding(ivars[i])); | |
} | |
free(ivars); | |
classType = [classType superclass]; | |
} while (classType != nil); | |
printf("\n"); | |
} | |
static void printPropertiesList(Class classType) { | |
printf("\n"); | |
do { | |
unsigned int count; | |
objc_property_t *properties = class_copyPropertyList(classType, &count); | |
for(unsigned int i = 0; i < count; i++) { | |
printf("%s::%s %s\n", [classType description].UTF8String, property_getName(properties[i]), property_getAttributes(properties[i])+1); | |
} | |
free(properties); | |
classType = [classType superclass]; | |
} while (classType != nil); | |
printf("\n"); | |
} | |
static void printMethodsList(Class classType) { | |
printf("\n"); | |
do { | |
unsigned int count; | |
Method* methods = class_copyMethodList(classType, &count); | |
for(unsigned int i = 0; i < count; i++) { | |
struct objc_method_description *description = method_getDescription(methods[i]); | |
printf("%s::%s %s\n", [classType description].UTF8String, sel_getName(description->name), description->types); | |
} | |
free(methods); | |
classType = [classType superclass]; | |
} while (classType != nil); | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment