0

現在、オブジェクトのグループをサーバーに送信する必要があるインスタンスがいくつかあります。

{
    "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]]];

不必要なオーバーヘッドのようです。配列を保持する中間オブジェクトなしでこれを行う方法はありますか?

4

1 に答える 1

1

シリアル化中に使用される構造を提供するには、中間オブジェクトが必要です。ただし、カスタム クラスである必要はありません。NSDictionary正しいキーとNSArray値を含むだけでかまいません。

于 2013-08-14T13:09:55.617 に答える