Edit: Change your code from line 3 (including) to:
NSDictionary * json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
NSArray *meta = json[@"objects"];
for (NSDictionary *aDict in meta) {
NSDictionary *location = aDict[@"location"];
NSLog(@"%@", location);
}
This NSLog()
s all the locations in your JSON response
.
If you want the city
and country
only once you can do the following:
NSDictionary *location = json[@"objects"][0][@"location"];
NSString *country = location[@"country"];
NSString *locality = location[@"locality"];
NSLog(@"country: %@", country);
NSLog(@"locality: %@", locality);
Output:
country: Germany
locality: Hauzenberg