目前,我有几个需要将一组对象发送到服务器的实例:
{
"things": [
{
//object stuff
},
{
//object stuff
},
...
]
}
所以我一直在做的是定义一个中间对象MyThingPayload
@interface MyThingPayload
@property (nonatomic, strong) NSArray *things;
@end
然后在映射时
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:NSClassFromString(@"MyThingPayload")];
[mapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"things"
toKeyPath:@"things"
withMapping:[self entityMappingForManagedThingObject]]];
似乎是不必要的开销。如果没有包含数组的中间对象,有没有办法做到这一点?