I have a document that sometimes looks like this:
<doc> <titleInfo> <title>One version of the title</title> </titleInfo> <titleInfo> <title>Another version</title> </titleInfo> </doc>
But sometimes it looks like this:
<doc> <titleInfo> <title>This is the only version of the title</title> </titleInfo> </doc>
I am trying to match this with an array in my object with the following:
[mapping mapKeyPath:@"titleInfo.title" toAttribute:@"titles"];
This works in the first case, but in the second case I get
RKObjectMappingOperation.m:199 Failed transformation of value at keyPath 'titleInfo.title'. No strategy for transforming from '__NSCFString' to 'NSArray'
It is clear that RestKit correctly interprets the first document as containing an array of strings, but in the case of the second document I cannot find a way to force this interpretation.
Is there an easy way to express this using KVC tools in RestKit, or am I better off writing some kind of fully customizable mapper?
source share