以下是给定的JSON内容:
{
"someKey":"someValue",
"otherKey":"otherValue",
"features":[
"feature1",
"feature2",
"feature3"
]
}
我正在使用
RKMapperOperation
和RKEntityMapping
将此JSON映射到NSManagedObject
中(在此示例中,我将有两个实体映射:一个用于顶级对象,另一个用于我的Feature类)。顶级对象映射很简单:两个属性映射加上与Feature的关系映射(features)。
我的问题是,如何将features JSON数组映射为Feature对象数组? 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
有什么想法吗?