Mapping Objects in Arrays - fcanas/OHMKit GitHub Wiki

Arrays

Arrays of dictionaries can be mapped to a class as well.

(This array feature is not included in the 0.0.5 release. It is present at the head of the master branch.)

@interface Person : NSObject
@property (nonatomic, copy) NSString *name;
@end

@interface Roster : NSObject
@property (nonatomic, strong) NSArray *people;
@end

OHMMappable([Person class]);
OHMSetArrayClasses([Roster class], @{@"people":[Person class]});

NSDictionary *response = @{@[@{@"name":@"Bert"},
                             @{@"name":@"Ernie"},
                             @{@"name":@"Count"}];

Roster *roster = [Roster new];
[roster setValuesForKeysWithDictionary:response];