JSON和嵌套的NSDictionary

Ale*_*Tau 1 parsing json objective-c nsdictionary

在解析JSON响应之后,我得到一个包含其他字典的NSDictionary,这些字典是一些事先未知的键的值(308,1):

{
"308":{
    "id":"308",
    .....

},
"1":{
    "id":"1",
    .....
     }
}
Run Code Online (Sandbox Code Playgroud)

我怎么在这里使用valueForKey,因为我不知道密钥?如何访问嵌套字典?谢谢!

Ole*_*man 5

NSDictionary *myDict;
...

NSArray *keys = [myDict allKeys]; //NSArray of dictionary's keys

for (id key in keys) //'foreach' loop for all keys
{
   id aValue = [myDict objectForKey: key]; //getting object from the dictionary
   if([aValue isKindOfClass:[NSDictionary class]])
   {
       //Object is a nested dictionary
       ...
   }
}
Run Code Online (Sandbox Code Playgroud)