I am trying to learn reflection in Objective-C. I\'ve found some great information on how to dump the property list of a class, especially here, but I want to know if it is
Objective C properties automatically conform to the NSKeyValueCoding protocol. You can use setValue:forKey: to set any property value by a string property name.
NSDictionary * objectProperties = @{@"propertyName" : @"A value for property name",
@"anotherPropertyName" : @"MOAR VALUE"};
//Assuming class has properties propertyName and anotherPropertyName
NSObject * object = [[NSObject alloc] init];
for (NSString * propertyName in objectProperties.allKeys)
{
NSString * propertyValue = [objectProperties valueForKey:propertyName];
[object setValue:propertyValue
forKey:propertyName];
}