Created
July 28, 2015 21:55
-
-
Save justAnotherDev/7d91a2c7e5f0f0dacb1b 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 *)allInstanceVariablesForClass:(Class)klass { | |
NSMutableArray *iVarList = [NSMutableArray array]; | |
unsigned int count; | |
Ivar* ivars=class_copyIvarList(klass, &count); | |
for(int i=0; i < count; i++) { | |
Ivar ivar= ivars[i]; | |
// see if this ivar should be ignored | |
NSString *key = [NSString stringWithFormat:@"%s", ivar_getName(ivar)]; | |
[iVarList addObject:key]; | |
} | |
free(ivars); | |
return iVarList; | |
} | |
- (NSArray *)allPropertiesForClass:(Class)klass { | |
NSMutableArray *propertyList = [NSMutableArray array]; | |
unsigned int count; | |
objc_property_t* properties = class_copyPropertyList(klass, &count); | |
for(int i=0; i < count; i++) { | |
objc_property_t ivar= properties[i]; | |
// see if this ivar should be ignored | |
NSString *key = [NSString stringWithFormat:@"%s", property_getName(ivar)]; | |
[propertyList addObject:key]; | |
} | |
free(properties); | |
return propertyList; | |
} | |
- (NSArray *)allClassMethodsForClass:(Class)klass { | |
NSMutableArray *methodList = [NSMutableArray array]; | |
unsigned int count; | |
Method* methods = class_copyMethodList(object_getClass(klass), &count); | |
for (int i = 0; i < count; i++) { | |
Method method = methods[i]; | |
NSString *key = NSStringFromSelector(method_getName(method)); | |
[methodList addObject:key]; | |
} | |
free(methods); | |
return methodList; | |
} | |
- (NSArray *)allInstanceMethodsForClass:(Class)klass { | |
NSMutableArray *methodList = [NSMutableArray array]; | |
unsigned int count; | |
Method* methods = class_copyMethodList(klass, &count); | |
for (int i = 0; i < count; i++) { | |
Method method = methods[i]; | |
NSString *key = NSStringFromSelector(method_getName(method)); | |
[methodList addObject:key]; | |
} | |
free(methods); | |
return methodList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment