to display weather forecast for currentday,next day and day after next day in iphone [closed]

[亡魂溺海] 提交于 2019-12-08 13:43:11

问题


Hi i want to create a weather application.My weather application is such that when user clicks on weather tab weather details of the current location should be displayed in table view.For the same current location,weather details for the current day ,next day and day after next day should be displayed in tableview.please anybody give me any sort of code or any link on how this is possible in iphone. Thanks


回答1:


You will have to use NSDate ,

First Construct an NSDate object with current time

NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss"];
NSString *currentTime = [dateFormatter stringFromDate:today];
[dateFormatter setDateFormat:@"dd.MM.yyyy"];
NSString *currentDate = [dateFormatter stringFromDate:today];

Now currentDate is the string object, you can display it with UILabel on screen,

likewise you could create date and get the string object for Next day .....

WeatherAPI

These are not iPhone specific, but free weather APIs.

NOAA REST Interface

Example: http://www.weather.gov/forecasts/xml/sample_products/browser_interface/ndfdXMLclient.php?zipCodeList=90210&product=time-series&begin=2004-01-01T00:00:00&end=2013-04-21T00:00:00&maxt=maxt&mint=mint

Yahoo! Weather Forecast RSS

Example: http://weather.yahooapis.com/forecastrss?p=90210

Google Weather API - documentation URL for this?

Example: http://www.google.com/ig/api?weather=90210

Weather Underground API

Example: http://api.wunderground.com/auto/wui/geo/GeoLookupXML/index.xml?query=90210

Weather Channel - Requires signup

Example: found sample code at github. Ruby gem for accessing the Weather Channel XML API

WeatherAPI (Norway)

Example: http://api.yr.no/weatherapi/locationforecast/1.6/?lat=34;lon=-118




回答2:


To display weather information in application you can use the following weather data feed(supports the following formats XML/JSON/CSV).

Weather API

You can use TouchXML for parsing XML(if the data feed return type is XML fromat).

TouchXML



来源:https://stackoverflow.com/questions/5775488/to-display-weather-forecast-for-currentday-next-day-and-day-after-next-day-in-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!