2013-03-07 25 views

回答

0

你不能。 在JSON/RESTKIT中,你不能提供一个递归结构的ob对象。 只需尝试一次获取对象级别,如果想要更深入地探索一个新的查询。

如果有人访问此属性,那么您的'节点'类应该具有'节点'属性,并使用一种延迟加载。

+0

我有点想到这一个。我结束了自己的解析器。 – Weston 2013-03-15 15:17:40

+0

这是不正确的。 – fumoboy007 2013-03-17 22:20:03

0

如果失败:

RKEntityMapping *nodeMapping = [RKEntityMapping mappingForEntityForName:@"Node" inManagedObjectStore:managedObjectStore]; 
[locationIconMapping addAttributeMappingsFromDictionary:@{ 
    @"name": @"name", 
    @"type": @"type", 
}]; 
[nodeMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"nodes" toKeyPath:@"nodes" withMapping:nodeMapping]]; 

那么怎么样:

RKEntityMapping *nodeMapping1 = [RKEntityMapping mappingForEntityForName:@"Node" inManagedObjectStore:managedObjectStore]; 
[nodeMapping1 addAttributeMappingsFromDictionary:@{ 
    @"name": @"name", 
    @"type": @"type", 
}]; 

RKEntityMapping *nodeMapping2 = [RKEntityMapping mappingForEntityForName:@"Node" inManagedObjectStore:managedObjectStore]; 
[nodeMapping2 addAttributeMappingsFromDictionary:@{ 
    @"name": @"name", 
    @"type": @"type", 
}]; 

[nodeMapping1 addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"nodes" toKeyPath:@"nodes" withMapping:nodeMapping2]]; 
[nodeMapping2 addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"nodes" toKeyPath:@"nodes" withMapping:nodeMapping1]]; 
+0

是的,但由于某种原因,它映射到它的自我,这意味着节点实例1将将节点实例1映射为其父节点和子节点。 – Weston 2013-03-07 18:34:45