Reputation: 2045
Currently I have several instances where I need to send a group of objects to the server:
{
"things": [
{
//object stuff
},
{
//object stuff
},
...
]
}
So what I've been doing is defining an intermediate object MyThingPayload
@interface MyThingPayload
@property (nonatomic, strong) NSArray *things;
@end
And then when mapping
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:NSClassFromString(@"MyThingPayload")];
[mapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"things"
toKeyPath:@"things"
withMapping:[self entityMappingForManagedThingObject]]];
Seems like unnecessary overhead. Is there a way to do this without the intermediate object that holds an array?
Upvotes: 0
Views: 101
Reputation: 119031
You need an intermediate object to provide the structure to be used during serialisation. It doesn't need to be a custom class though, it can just be an NSDictionary
containing the correct key and NSArray
value.
Upvotes: 1