Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Displaying Google JSON
I've tried to do the extra credit exercise for the "Getting Data From Web" stage and I just can't find out why my code isn't working. Check the google JSON return: http://d.pr/i/RhGJ
NSURL *blogURL = [NSURL URLWithString:@"https://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Design"]; //I've put the results array, not sure if that responseData affects something self.blogPosts = [dataDictionary objectForKey:@"results"];
and here to add it into my cell
cell.textLabel.text = [blogPost valueForKey:@"titleNoFormatting"]; cell.detailTextLabel.text = [blogPost valueForKey:@"content"];
Did anyone was able to do this exercise? Do you know what's the problem on my code?
Thomas AnthonyiOS Development Techdegree Student 22,352 Points
The reason you are having this issue is because you are trying to access an object with an undefined key:
results. You need to access the result array within the responseData object like so:
self.blogPosts = [[dataDictionary objectForKey:@"responseData"] objectForKey:@"results"];
self.blogPosts = dataDictionary[@"responseData"][@"results"];
i had the same problem and now it solved. thanks Thomas Anthony.