get values of particular key in nsdictionary

前端 未结 3 2036
醉话见心
醉话见心 2020-12-24 07:55

I saved the json parsing result in a dictionary which look like:

{
 \"statusCode\":\"200\",
\"body\":[
  {
     \"status\":\"succes         


        
3条回答
  •  失恋的感觉
    2020-12-24 08:11

    Following will give you the desired object

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

    For individual:

    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"];
    

    Also,

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

提交回复
热议问题