Skip to content

Instantly share code, notes, and snippets.

@loganwright
Last active August 29, 2015 14:01
Show Gist options
  • Save loganwright/912b1a23f157501572e1 to your computer and use it in GitHub Desktop.
Save loganwright/912b1a23f157501572e1 to your computer and use it in GitHub Desktop.
Property Names / Attributes of Class
#import <objc/runtime.h>
- (NSArray *) getPropertyNamesForClass:(Class)class {
NSMutableArray * propertyNames = [NSMutableArray array];
// Fetch Properties
unsigned count;
objc_property_t *properties = class_copyPropertyList(class, &count);
// Parse Out Properties
for (int i = 0; i < count; i++) {
objc_property_t property = properties[i];
const char * name = property_getName(property);
NSString * propertyName = [NSString stringWithUTF8String:name];
[propertyNames addObject:propertyName];
}
// Free our properties
free(properties);
return propertyNames;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment