开发者

Travel Application Airport code returns City,Country

开发者 https://www.devze.com 2023-03-13 08:49 出处:网络
I am trying to develop an travel application.I would like to submitthe Airport code a开发者_如何学编程nd get back the Country,City, along with the weather of that particular space.Is there an API out

I am trying to develop an travel application.I would like to submit the Airport code a开发者_如何学编程nd get back the Country,City, along with the weather of that particular space.Is there an API out in the market that will help me in doing that???Or is there some other way I can do that?


Here's one for the city/country: http://airportcode.riobard.com/about

and this question has good info about weather: Weather API - Provides "About to..." Information?

Here's a sample piece of code that accepts the text from 'inputTextField' and outputs the location to 'outputLabel'

-(IBAction)getCity{
NSString *urlString = [NSString stringWithFormat:@"http://airportcode.riobard.com/airport/%@?fmt=json",self.inputTextField.text];
NSURL *url = [NSURL URLWithString:urlString];
NSString *response = [[NSString alloc] initWithContentsOfURL:url];
const char *convert = [response UTF8String];
NSString *responseString = [NSString stringWithUTF8String:convert];
NSDictionary *airport = [responseString JSONValue];
self.outputLabel.text=[airport objectForKey:@"location"];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消