You need to use Objective C run-time libraries for this
#import <objc/runtime.h>
- (NSSet *)propertyNames {
NSMutableSet *propNames = [NSMutableSet set];
unsigned int outCount, i;
objc_property_t *properties = class_copyPropertyList([self class], &outCount);
for (i = 0; i < outCount; i++) {
objc_property_t property = properties[i];
NSString *propertyName = [NSString stringWithCString:property_getName(property) encoding:NSUTF8StringEncoding];
[propNames addObject:propertyName];
}
free(properties);
return propNames;
}
- (void)loopThrough {
for(NSString *key in [self propertyNames]) {
NSLog (@"value = %@ , property %@",[self valueForKey:key],key);
}
}