Skip to content

Instantly share code, notes, and snippets.

@christianroman
Created August 20, 2012 20:35
Show Gist options
  • Save christianroman/3407636 to your computer and use it in GitHub Desktop.
Save christianroman/3407636 to your computer and use it in GitHub Desktop.
Get Property Type from an Object
static char *getPropertyType(objc_property_t property) {
const char *attributes = property_getAttributes(property);
const char *start;
int len = strlen(attributes);
if (len >= 3 && attributes[0] == 'T' && attributes[1] == '@' && attributes[2] == '"') {
start = attributes + 3;
char *end = strchr(start, '"');
if (end) {
char *type = malloc((end - start) * sizeof(char) + 1);
strncpy(type, start, end - start);
type[end - start] = '\0';
return type;
}
else
return "";
}
else
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment