在nsdictionary中获取特定键的值

我将jsonparsing结果保存在一个dictionary ,如下所示:

 { "statusCode":"200", "body":[ { "status":"success", "remarks":null } ], "data":[ "abcd":[ { "category":"a", "title":"b", "id":"24" }, { "category":"c", "title":"crd", "id":"65" }, { "category":"ds", "title":"sd", "id":"18" } ] }, { "efgh":[ { "category":"ds", "title":"sd", "id":"18" }, { "category":"sd", "title":"sd", "id":"1" } ] }, { "ijkl":[ { "category":"ds", "title":"sd", "id":"18" }, { "category":"sd", "title":"sd", "id":"1" } ] } ] } 

key @“data”的数据可以通过使用保存到数组中

 NSMutableArray *getdata=[[NSMutableArray alloc]init]; getcat=[results objectForKey:@"data"]; 

现在我应该怎么做第一个索引内的values(category, title, id) ,即"abcd"

如果有人有任何知识,请看看。

谢谢大家。

以下将给你所需的对象

 NSDictionary *dict=[results valueForKeyPath:@"data.abcd"][0]; 

对于个人:

 NSString *categoryString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"Category"]; NSString *idString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"id"]; NSString *titleString=[[results valueForKeyPath:@"data.abcd"][0] objectForKey:@"title"]; 

也,

 NSString *categoryString=dict[@"Category"]; NSString *idString=dict[@"id"]; NSString *titleString=dict[@"title"]; 

像这样检查:

 NSString *value=[[[getcate valueForKey:@"abcd"] objectAtIndex:0] valueForKey:@"category"]; 

这是一个数组,所以使用objectAtIndex:[getcat objectAtIndex:0]getcat[0]