I have a function, that recieves an object, a name of a property and its value. Could i set the property of the object with something simple like this:
-(void)dynamicSetterWithProperty:(NSString*)propertyThatIsKnownOnlyInRuntime
andValue:(NSString*)valueThatIsKnownOnlyInRuntime{
_myObject.propertyNameThatIsKnownOnlyInRuntime = valueNameThatIsKnownOnlyInRuntime;
}
Or do I have to do it in this ugly way:
-(void)dynamicSetterWithProperty:(NSString*)propertyThatIsKnownOnlyInRuntime
andValue:(NSString*)valueThatIsKnownOnlyInRuntime{
if([propertyNameThatIsKnownOnlyInRuntime isEqualToString@"name"]){
_myObject.name = valueNameThatIsKnownOnlyInRuntime;
}
else if([propertyNameThatIsKnownOnlyInRuntime isEqualToString@"age"]){
_myObject.age = valueNameThatIsKnownOnlyInRuntime;
}
}