Basic Object Mapping - fcanas/OHMKit GitHub Wiki
Given a model class
@interface MYModel : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *favoriteWord;
@property (nonatomic, assign) NSInteger favoriteNumber;
@end
Anywhere in you application, make the model mappable, and assign it a dictionary of mappings from the keys a service will provide to the keys your actual model object uses.
OHMMappable([MYModel class]);
OHMSetMapping([MYModel class], @{@"favorite_word" : @"favoriteWord",
@"favorite_number": @"favoriteNumber");
And now anywhere in your application, objects of the class MYModel
can be hydrated with a dictionary from a service whose keys will be translated by the mapping dictionary you provided.
MYModel *testModel = [[MYModel alloc] init];
[testModel setValuesForKeysWithDictionary:@{@"name" : @"Fabian",
@"favorite_word" : @"absurd",
@"favorite_number": @47];