【发布时间】:2014-03-29 13:12:57
【问题描述】:
我正在使用航班感知服务获取航班信息,但我无法以我可以使用的方式获取数据。
Json 响应为:
{
"AirlineInfoResult": {
"name": "US Airways",
"shortname": "US Airways",
"callsign": "Cactus",
"location": "Tempe, AZ",
"country": "United States",
"url": "http://www.usairways.com/",
"phone": "+1-800-428-4322"
}
}
这是我正在使用的代码,但没有返回任何内容
NSMutableDictionary * routeRes;
routeRes = [json objectForKey: @"AirlineInfoResult"];
NSMutableArray * res;
res = [json objectForKey: @"url"];
for (NSMutableDictionary * flight in res) {
NSLog(@"actual arrival time= %@", [flight objectForKey: @"url"]);
}
我在获取这些数据时遗漏了什么?
【问题讨论】:
-
res应该是NSString。 -
请给出回复的网址
-
url响应是顶部
-
如果我将 res 更改为 NSString,我会收到此错误 NSInvalidArgumentException',原因:'-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x7fff72f4af10
-
在您的回答中,您没有“实际到达时间”。和
res = [routeRes objectForKey:@"url"];
标签: ios objective-c json parsing