Say the following JSON answer is given to me
{
"images": [
"http://domain.com/image1.jpg",
"http://domain.com/image2.jpg",
"http://domain.com/image3.jpg"
]
}
With Mantle, I want to parse these strings and convert them to NSURL, but store them in NSArray.
So my Objective-C model object will look like
@interface MyModel : MTLModel <MTLJSONSerializing>
@property (nonatomic, copy, readonly) NSArray *images;
@end
Is there an elegant way to achieve this? Some NSURL array transformers?
+ (NSValueTransformer*)imagesJSONTransformer
{
return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:[NSURL class]];
}
Obviously, NSURL is not the result of MTLModel, so this will not work.
source
share