It's not a good approach you may find another way to solve your issue but if you want to have an idea about your requested solution here here my try
Our properties
@interface TestyViewController ()
@property (nonatomic) NSNumber* a;
@property (nonatomic) NSNumber* b;
@property (nonatomic) NSNumber* c;
@property (nonatomic) NSNumber* d;
@end
Set the values
- (void)viewDidLoad {
[super viewDidLoad];
self.a=@(1);
self.b=@(2);
self.c=@(3);
self.d=@(4);
}
Get our instance variables
-(NSArray *)propertyNames{
unsigned int propertyCount = 0;
objc_property_t * properties = class_copyPropertyList([self class], &propertyCount);
NSMutableArray * propertyNames = [NSMutableArray array];
for (unsigned int i = 0; i < propertyCount; ++i) {
objc_property_t property = properties[i];
const char * name = property_getName(property);
[propertyNames addObject:[NSString stringWithUTF8String:name]];
}
free(properties);
return propertyNames;
}
Create the dictionary
- (IBAction)buttonClicked:(id)sender
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
for (NSString* varName in [self propertyNames])
{
[dict setObject:[self valueForKey:varName] forKey:varName];
}
NSLog(@"%@",dict);
}
result
2015-07-15 20:30:56.546 TestC[879:27973] {
a = 1;
b = 2;
c = 3;
d = 4;
}