RestKit/RestKit — Issue #536: Mixed 1 or n numbers of nodes confuses Restkit
Author: besi
Created: 2012-01-27 12:29:39+00:00
State: open

I have the following XML which seems to be confusing for RestKit:

The Bible

Isaiah
Moses

The Hitchhikers Guide to the Galaxy

Douglas Adams

My Mapping looks like this:

RKObjectManager *manager = [[RKObjectManager alloc]initWithBaseURL:kBaseURL];
[RKObjectManager setSharedManager:manager];

RKObjectMapping* bookMapping = [RKObjectMapping mappingForClass:[Book class]];
[bookMapping mapKeyPath:@"title" toAttribute:@"bookTitle"];
[bookMapping mapKeyPath:@"author" toAttribute:@"bookAuthors"]; // bookAuthors is an Array of the `Book` class.

[[RKObjectManager sharedManager].mappingProvider setMapping:bookMapping forKeyPath:@"books.book"];

Now the entry with two authors is correctly parsed and the array then contains two entries, but for the other case I get a warning like this:

Failed transformation of value at keyPath 'author'. No strategy for transforming from '__NSArrayM' to 'NSString'

Is there a way that also the "lone" entry is mapped into the array. Please note that I can not change the structure of the XML.