我有一个Parent
继承自的模型NSManagedObject
和一个Child
继承自 的模型Parent
。
这是Parent
映射:
RKManagedObjectStore* store = [RKObjectManager sharedManager].objectStore;
RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForEntityWithName:@"Parent" inManagedObjectStore:store];
[mapping mapKeyPath:@"id" toAttribute:@"id"];
[[RKObjectManager sharedManager].mappingProvider addObjectMapping:mapping];
和Child
映射:
RKManagedObjectStore* store = [RKObjectManager sharedManager].objectStore;
RKManagedObjectMapping* mapping = [RKManagedObjectMapping mappingForEntityWithName:@"Child" inManagedObjectStore:store];
[[RKObjectManager sharedManager].mappingProvider setMapping:mapping forKeyPath:@"child"];
然后,当我尝试将以下 JSON 对象映射到Child
实例时:
{
"child": {
"id": 7
}
}
在 RestKit 跟踪中,我看到以下映射Child
:
mappings => ()
为什么映射不从Child
映射继承Parent
?如何使映射继承工作?