我有时候会得到这样的文档:
<doc>
<titleInfo>
<title>One version of the title</title>
</titleInfo>
<titleInfo>
<title>Another version</title>
</titleInfo>
</doc>
但有时它看起来像这样:
<doc>
<titleInfo>
<title>This is the only version of the title</title>
</titleInfo>
</doc>
我正在尝试将此内容映射到我的对象中的数组,代码如下:
[mapping mapKeyPath:@"titleInfo.title" toAttribute:@"titles"];
这在第一个案例中有效,但在第二个案例中,我收到以下错误:
RKObjectMappingOperation.m:199 Failed transformation of value at keyPath 'titleInfo.title'. No strategy for transforming from '__NSCFString' to 'NSArray'
显然,RestKit正确解释了第一个文档包含字符串数组--但是对于第二个文档,我找不到强制相同解释的方法。
在RestKit的KVC工具中,是否有一种简单的表达方式,或者我最好编写一些完全定制的映射器?