我在这里解析 JSON 并正确获取数据。但是,当我尝试将信息放入 NSDictionary 并阅读时,我收到此错误
'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKey:]: unrecognized selector sent to instance 0x1cda3d50'
这是代码
if (data != nil) {
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
NSDictionary *dic = [[res objectForKey:@"data"] objectForKey:@"current_condition"];
self.location = [[dic objectForKey:@"request"]objectForKey:@"query"];
}
关于这里出了什么问题的任何想法?谢谢。
编辑
这是我登录 NSDictionary *res 时得到的
data = {
"current_condition" = (
{
cloudcover = 100;
humidity = 86;
"observation_time" = "11:11 PM";
precipMM = "2.2";
pressure = 1019;
"temp_C" = 1;
"temp_F" = 34;
visibility = 8;
weatherCode = 296;
weatherDesc = (
{
value = "Light rain";
}
);
weatherIconUrl = (
{
value = "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0033_cloudy_with_light_rain_night.png";
}
);
winddir16Point = SSW;
winddirDegree = 210;
windspeedKmph = 15;
windspeedMiles = 9;
}
);
request = (
{
query = "North Massapequa, United States Of America";
type = City;
}
);
}