I have a JSON object like so:
{
"name": "Brendan",
"images": ["some.url.to.image1",
"some.url.to.image2",
"some.url.to.image3"]
}
My class is as follows:
@interface MyModel : MTLModel <MTLJSONSerializing>
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSArray *images;
@end
@implementation MYModel
+ (NSDictionary*)JSONKeyPathsByPropertyKey {
return @{
@"name" : @"name",
@"images" : @"images"
};
}
@end
I can verify that MYModel object has name properly set, but images is set to null. How can I populate an array of strings with Mantle?
Update: Apparently
mtl_externalRepresentationArrayTransformerWithModelClass:is deprecated. This might work:You need to specify value transformer for key
imagesas Array value transformer. You can do this with class method (on yourMyModelclass) with correct name. Something like this might work. I have not tested the code.