Created
March 15, 2012 00:43
-
-
Save kickingvegas/2040761 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
- (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