objective c - RestKit: Composing Relationships with the Nil Key Path -
i have 2 classes
- author attributes id, papers (paper relationship), ...
- paper attributes id, mainauthor (author relationship), authors (author relationship) ...
and want map json it
"authors": [ { "id": 123, "papers": [ { "id": 1, "main_author_id": 123, ... }, ... ] }, ... ]
the problem json not structured
"authors": [ { "id": 123, "papers": [ { "id": 1, "main_author": { "id": 123 } ... }, ... ] }, ... ]
so map things (note *main_author* part of both json examples). tried using mapping value without key path explained here:
[authormapping addattributemappingtokeyofrepresentationfromattribute:@"main_author_id"]; [authormapping addattributemappingsfromdictionary:@{@"(main_author_id)": @"id"}];
but i'm getting error telling me keypath id exists , may not add second mapping keypath. totally understand error, have no idea how map *main_author_id* id. changing data source may best solution, unfortunately not possible.
any suggestion highly welcome! thanks!
this foreign key mapping for. allows temporarily store 'identity' value you're provided , restkit find appropriate object , complete relationship.
Comments
Post a Comment