-2

I'm using afnetworking to fetch my json files on the server.

 [manager GET:@"http://pathtojson.com/iPhone/test.json" parameters:nil success:^(AFHTTPRequestOperation *operation, NSArray * responseObject) {
        NSDictionary *test = (NSDictionary *)responseObject;

        NSLog(@"%@", test[@"url"]);}

My json file is like this :

{ "images" : { 
           "items" : 
                  [{"url" : "myurl.com", "title" :"Night drops"}, {"url" : "myurl2.com","title" : "Test 2 colors"}]
              }
 }

And what I am trying to do is to get the url and the title in an array in order to use it. When I print the entry url the answer is null.

How can I do to get the 2 entries ?

thank you guys !

Larme
  • 24,190
  • 6
  • 51
  • 81
Jeromiin
  • 71
  • 7
  • Similar Thread http://stackoverflow.com/questions/5547311/how-do-i-parse-json-with-objective-c – Mike May 15 '14 at 15:27

1 Answers1

1

From the JSON you gave, it looks like you want test[@"images"][@"items"][0][@"url"] or test[@"images"][@"items"][1][@"url"].

Isaac
  • 10,668
  • 5
  • 59
  • 68