iOS: 如何从一个字典中的数组中的对象中获取值?
iOS: How can I get value from object which is inside an array, which is inside one dictionary?
我收到这样的 JSON:
{
response = {
message = (
"Permission denied, you do not have permission to access the requested page."
);
};
}
我要打印:
"Permission denied, you do not have permission to access the requested page."
如何获取值?
在Objective 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);
}
我收到这样的 JSON:
{
response = {
message = (
"Permission denied, you do not have permission to access the requested page."
);
};
}
我要打印:
"Permission denied, you do not have permission to access the requested page."
如何获取值?
在Objective 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);
}