Let's say given to me is the following JSON response
{
"images": [
"http://domain.com/image1.jpg",
"http://domain.com/image2.jpg",
"http://domain.com/image3.jpg"
]
}
With Mantle I want to parse those strings and transform them into NSURLs but keep them in an NSArray.
So my Objective-C model object would look like
@interface MyModel : MTLModel <MTLJSONSerializing>
// Contains NSURLs, no NSStrings
@property (nonatomic, copy, readonly) NSArray *images;
@end
Is there an elegant way to achieve that? Some NSURL array transformer?
+ (NSValueTransformer*)imagesJSONTransformer
{
return [NSValueTransformer mtl_JSONArrayTransformerWithModelClass:[NSURL class]];
}
Obviously NSURL does not derive from MTLModel, so that will not work.