-1

I've tried to get the Google JSON data and put on my UITableView, but it's not showing up.

Check the google JSON return:

Google JSON

I've got the JSON and put on my dictionary already like you would do with a normal JSON, but the google one isn't working.

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 know if I need to do something different than a normal JSON feed for google? My code seems right but it's not working

PS: I've did the NSDictionary and NSData to store the JSON already, I just didn't posted here because I don't think it matters.

Girish
  • 4,692
  • 4
  • 35
  • 55
Rodrigo Parra
  • 243
  • 1
  • 3
  • 16

1 Answers1

1

By looking at the JSON data I can say that the way of retrieving the data from the dictionary is wrong.

You should use like the following

self.blogPosts = [[dataDictionary objectForKey:@"responseData"]objectForKey:@"results"];

In your case that self.blogPosts is nil.

Prasad Devadiga
  • 2,573
  • 20
  • 43
  • Thank you so much, I didn't knew you had to access the first array first in order to get the objects from the second one. – Rodrigo Parra May 31 '13 at 05:05
  • @RodrigoParra It goes like this - from dataDictionary you are taking the dictionary for key `responseData` and from that dictionary you are taking an array which is stored for key `results`. – Prasad Devadiga May 31 '13 at 05:29