Skip to content

Instantly share code, notes, and snippets.

@kickingvegas
Created March 15, 2012 00:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kickingvegas/2040761 to your computer and use it in GitHub Desktop.
Save kickingvegas/2040761 to your computer and use it in GitHub Desktop.
- (NSArray *)allKeys {
NSMutableArray *result;
NSMutableArray *classList;
classList = [[NSMutableArray alloc] init];
result = [[NSMutableArray alloc] init];
Class cls = [self class];
Class nsObjectClass = [NSObject class];
while (cls != nsObjectClass) {
const char *className = class_getName(cls);
NSLog(@"%@", [NSString stringWithCString:className encoding:NSUTF8StringEncoding]);
[classList addObject:cls];
cls = [cls superclass];
}
unsigned int propertyCount = 0;
for (Class cls in classList) {
objc_property_t *properties = class_copyPropertyList(cls, &propertyCount);
for (unsigned int i = 0; i < propertyCount; ++i) {
objc_property_t property = properties[i];
const char *name = property_getName(property);
NSString *key = [NSString stringWithUTF8String:name];
[result addObject:key];
}
free(properties);
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment