2013-03-07 10 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