给定以下 JSON:
{
"someKey":"someValue",
"otherKey":"otherValue",
"features":[
"feature1",
"feature2",
"feature3"
]
}
我用 and 将这个 JSON 映射到sNSManagedObject
中(在这个例子中,我将有 2 个实体映射:一个用于顶级对象,另一个用于我的要素类)。RKMapperOperation
RKEntityMapping
顶级对象映射是微不足道的:两个属性映射加上一个关系一个(特征),用于与 Feature 的关系。
我的问题是,如何将要素 JSON 数组映射到要素对象数组中?Feature 类只有一个属性name
,我想在其中存储“feature1”、“feature2”等以及对父对象(顶层对象)的引用。像这样的东西:
@interface Feature : NSManagedObject
//In the implementation file both properties are declared with @dynamic.
@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) MyTopLevelObject *myTopLevelObject;
@end
任何想法?