Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:我如何从数组中的对象中获取值,它在一个字典中?_Ios_Objective C_Nsarray_Nsdictionary - Fatal编程技术网

iOS:我如何从数组中的对象中获取值,它在一个字典中?

iOS:我如何从数组中的对象中获取值,它在一个字典中?,ios,objective-c,nsarray,nsdictionary,Ios,Objective C,Nsarray,Nsdictionary,我得到的JSON如下: { response = { message = ( "Permission denied, you do not have permission to access the requested page." ); }; } 我想打印: 权限被拒绝,您没有访问请求页面的权限 如何获得目标C中的值? NSArray *arrRes = [[jsonRes objectForKey:@"respon

我得到的JSON如下:

{
    response =  {
        message = (
            "Permission denied, you do not have permission to access the requested page."
        );
    };
}
我想打印:

权限被拒绝,您没有访问请求页面的权限

如何获得目标C中的值?

 NSArray *arrRes = [[jsonRes objectForKey:@"response"] objectForkey:@"message"];
 NSLog(@"The output result is - %@",arrRes);
然后,如果要打印数组中的字符串,请执行以下操作

for(int i=0;i<arrRes.count;i++){
        NSString *strRes = arrRes[i];
        NSLog(@"The strRes is - %@",strRes);
}

for(int i=0;i读大括号/圆括号
{}
是字典,键下标
()
为数组,下标为索引。字符串是根字典中key
response
的字典中key
message
的数组中的第一项。尝试将JSON解析作为第一步,您将了解其余内容。这将对您有所帮助-