Hey guys 🙂 I am quite new to stack overflow and iPhone programming. I am trying to parse a complex JSON to display some stuff in the UITableView.
a part of the JSON structure –
{"1":{"1":"Ent1","done":"No"},"2":{"1":"Ent2","done":"No"}}
I am able to parse through the main keys “1” and “2” and able to grab the values corresponding to the key “1” inside {“1″:”Ent1″,”done”:”No”}, {“1″:”Ent2″,”done”:”No”} store them into a dictionary/ a string with the following code :
for (NSString *key in dict)
{
NSString *answer = [dict objectForKey:@"1"];
NSLog(@"%@", answer);
}
The result is Ent1 and Ent2 because the code iterates over the for loop and checks for the objects with key “1”.
The problem is this – I want to store both the values(Ent1 and Ent2) into an array.
I use the following code:
NSMutableArray *array = [[NSMutableArray alloc] initWithObjects: answer, nil];
but it just takes the last index in the dictionary which is Ent2.
Could you please tell me how could I add both the values for key 1 into an array?
Thanks in advance 🙂
1 Answer