我有以下 JSON 结构:
{
"category": "MyCategory"
"objects": [
{ "id": 1, "name": "A" },
{ "id": 2, "name": "B" },
{ "id": 3, "name": "C" }
]
}
我将每个对象映射到一个单独的核心数据实体,如下所示:
RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"Object" inManagedObjectStore:manager.managedObjectStore];
mapping.identificationAttributes = @[ @"id" ];
[mapping addAttributeMappingsFromDictionary:@{ @"name": @"name" }];
如何配置映射以将其共享类别存储在每个对象上?
我想要的是能够像这样在 JSON 中向上遍历:
[mapping addAttributeMappingsFromDictionary:@{ @"name": @"name", @"PARENT.category": @"category" }];