Reputation: 241
list = ({
clouds = 24;
speed = "4.31";
temp = {
day = "283.84";
eve = "283.84";
night = "283.84";
};
}),
Please can anyone tell me what am I doing wrong - I want to display list-->temp-->day value in table first I am trying to get data in an array which is terminating. Here is my code am I doing any wrong
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:dataBuffer options:-1 error:nil];
NSLog(@"%@",json);
NSMutableDictionary * list = [json objectForKey:@"list"];
NSMutableArray *arrays = [[NSMutableArray alloc]initWithCapacity:0];
for (NSDictionary *lists in [list allValues]) {
[arrays addObject:[list valueForKey:@"temp"]];
}
Upvotes: 0
Views: 1279
Reputation: 4854
Your list is an array, so if you want to do your things without changing much, you can replace:
NSMutableDictionary * list = [json objectForKey:@"list"];
With:
NSMutableDictionary * list = [[json objectForKey:@"list"] objectAtIndex:0];
Upvotes: 0
Reputation: 17186
If you want to access day then use below line,
NSString *day = [json valueForKeyPath:@"list.temp.day"];
Upvotes: 1