Hi Richard,
Assuming that your leagues are loaded before your teams, then yes -
RestKit can do this for you rather easily. Steps to implement are as
follows. All steps are on the Team entity / JSON / mapping. There
should be no need to change the League entity / JSON / mapping (as you
already have leagueId defined as your primary key there). So:
1) Add a leagueId property to your Team entity (in addition to the
'league' relationship you already have defined there).
2) Ensure that the league_id is included in your Team JSON.
3) Map the JSON league_id onto the leagueId property, in the usual
fashion.
4) Connect the relationship by adding the following code at the end of
your Team mapping:
[teamMapping hasOne:@"league" withMapping:leagueMapping];
[teamMapping connectRelationship:@"league"
withObjectForPrimaryKeyAttribute:@"leagueId"];
That should do it!
I don't tend to monitor the group, so if you post a reply that I need
to read, then drop me a mail directly too so I know to take a look.
Cheers,
Dave
> [{"id":"1","name":"Barnsley","logo":"","league_id":"1","created_at":"132831 2288","updated_at":"1328312288"}]