I am using setValuesForKeysWithDictionary to populate my model object . Model object is defined as
@interface Media : NSObject
{
NSString *userId;
NSString *mediaType;
}
@property(nonatomic,copy) NSString *userId;
@property(nonatomic,copy) NSString *mediaType;
property synthesization looks like ,
@implementation Media
@synthesize userId;
@synthesize mediaType;
and I initialize the class as follows,
NSMutableDictionary *dic = [NSMutableDictionary new];
[dic setValue:@"aaa" forKey:@"userId"];
[dic setValue:@"bbb" forKey:@"mediaType"];
Media *obj = [[Media alloc] init];
[obj setValuesForKeysWithDictionary:dic];
This crashes with the message
'[<Media 0x8a9f280> valueForUndefinedKey:]: this class is not key value coding-compliant for the key aaa.'
How come setValuesForKeysWithDictionary: treat my value as the key ?? or have I misunderstood the purpose of the setValuesForKeysWithDictionary: function ?