我对以下XML有一个非常简单的RestKit映射:
<category name="religious">
<book isbn="42">HHGTTG</book>
<book isbn="7">The bible</book>
</category>
现在解析这个时,我得到一个category
对象,其中包含两个book
个对象。现在在我的book对象中,我希望引用category
。
这似乎是一件非常容易实现的事情,但我在Object Mapping Documentation中找不到任何内容。
更新:这就是我的映射:
RKObjectMapping *bookMapping = [RKObjectMapping mappingForClass:[Book class]];
[bookMapping mapKeyPath:@"isbn" toAttribute:@"isbn"];
RKObjectMapping* categoryMapping = [RKObjectMapping mappingForClass:[Category class]];
[categoryMapping mapKeyPath:@"name" toAttribute:@"name"];
// Relationship to book
[categoryMapping mapKeyPath:@"book" toRelationship:@"books" withMapping:bookMapping];