I am using Overcoat and Mantle.
Our JSON from our REST server returns something like:
{
results:[{
id: 123,
eventName: @"ABC"
...
private_users: [50, 37, 24]
},{
id: 124,
eventName: @"DEF"
...
private_users: [40, 27, 14]
},{
id: 125,
eventName: @"GHI"
...
private_users: [60, 47, 34]
},
]
}
So in this case, we have an Event entity and each event entity has a property called "private_users" which is an array of userID for each User entity.
If the above JSON had private_users containing an array of User entity instead of userID, I would already be able to map it using Mantle and Overcoat but the problem I am facing is, it's an array of userID.
I want to know how I can map/transform those userID in the private_users property using Mantle and Overcoat.
I am initially trying:
+(NSValueTransformer *)privateGroupsJSONTransformer
{
return [MTLValueTransformer transformerWithBlock:^NSArray *(NSArray *arrUserID) {
// create new User entities and assign each a userID from arrUserID ?
}];
}
Is that the right way to do it?
How do you normally store an array of integers in Mantle?
Any help on this would be great.