RestKit ios相同类型的嵌套对象

RestKit ios相同类型的嵌套对象,ios,xml-parsing,restkit,Ios,Xml Parsing,Restkit,如何映射相同类型的嵌套对象? 我有一个xml,其中的对象可能包含多个相同类型的对象: <entry location="l1"> <entry location="l1.1"> <entry location="l1.1.1"> </entry> <entry location="l1.1.2"> </entry> </entry>

如何映射相同类型的嵌套对象? 我有一个xml,其中的对象可能包含多个相同类型的对象:

<entry location="l1">
    <entry location="l1.1">
        <entry location="l1.1.1">
        </entry>
        <entry location="l1.1.2">
        </entry>
    </entry>
</entry>
是否可以将子对象添加到每个父对象的数组中

干杯

//编辑:以下代码适用于我:

+ (RKObjectMapping *)objectMapping
{
    RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Entry class]];
    [mapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    RKObjectMapping *innerMapping = [RKObjectMapping mappingForClass:[Entry class]];
    [innerMapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    [mapping addPropertyMapping:[RKRelationshipMapping
        relationshipMappingFromKeyPath:@"entry"
        toKeyPath:@"entries"
        withMapping:innerMapping]];

    return mapping;
}

我还没有试过,所以我不知道它是否有效,但试试这个:

+ (RKObjectMapping *)objectMapping
{
    RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Entry class]];
    [mapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    RKObjectMapping *innerMapping = [RKObjectMapping mappingForClass:[Entry class]];
    [innerMapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    [mapping addPropertyMapping:[RKRelationshipMapping
        relationshipMappingFromKeyPath:@"nextEntries"
        toKeyPath:@"entries"
        withMapping:innerMapping]];

    return mapping;
}
不确定
toKeyPath:@“entries”
是否正确,它可能需要基于XML的
toKeyPath:@“entries”


无限递归是因为您正在从自身调用相同的方法(
[Entry objectMapping]
),它与映射本身无关。

请接受正确的答案/帮助您解决问题。谢谢:)
+ (RKObjectMapping *)objectMapping
{
    RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Entry class]];
    [mapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    RKObjectMapping *innerMapping = [RKObjectMapping mappingForClass:[Entry class]];
    [innerMapping addAttributeMappingsFromDictionary:@{@"location": @"location"}];

    [mapping addPropertyMapping:[RKRelationshipMapping
        relationshipMappingFromKeyPath:@"nextEntries"
        toKeyPath:@"entries"
        withMapping:innerMapping]];

    return mapping;
}