Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

luke3

macrumors newbie
Original poster
Jun 6, 2012
23
0
I am playing with the ESPN Api and just trying to fill a tableview with all the teams in the NBA. I am using restkit and having some trouble.

below is some code RKURL *baseURL = [RKURL URLWithBaseURLString:mad:"http://api.espn.com"];

Code:
RKObjectManager *objectManager = [RKObjectManager objectManagerWithBaseURL:baseURL];
objectManager.client.baseURL = baseURL;

RKObjectMapping* taskMapping = [RKObjectMapping mappingForClass:[Team class]];
[taskMapping mapKeyPath:@"name" toAttribute:@"teamName"];
[objectManager.mappingProvider setObjectMapping:taskMapping forResourcePathPattern:@"/teams"];
[objectManager loadObjectsAtResourcePath:[NSString stringWithFormat:@"/v1/sports/basketball/nba/teams?apikey=%@",kAPIKey] delegate:self];


I get a response code 200 back, but I am getting the error

Code:
231 Encountered errors during mapping: Could not find an object mapping for keyPath

A sample of the JSON I am getting back for a team is below

Code:
{"sports" :[{"name" :"basketball","id" :40,"leagues" :[{"name" :"National Basketball Assoc.","abbreviation" :"nba","id" :46,"groupId" :7,"shortName" :"NBA","teams" :[{"id" :1,"location" :"Atlanta","name" :"Hawks","abbreviation" :"ATL","color" :"002B5C","links" :{"api" :{"teams" :{"href" :"http://api.espn.com/v1/sports/basketball/nba/teams/1"},"news" :{"href" :"http://api.espn.com/v1/sports/basketball/nba/teams/1/news"},"notes" :{"href" :"http://api.espn.com/v1/sports/basketball/nba/teams/1/news/notes"}},"web" :{"teams" :{"href" :"http://espn.go.com/nba/team/_/name/atl/atlanta-hawks?ex_cid=espnapi_public"}},"mobile" :{"teams" :{"href" :"http://m.espn.go.com/nba/clubhouse?teamId=1&ex_cid=espnapi_public"}}}}
 
Last edited by a moderator:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.