原文:http://blog.sina.com.cn/s/blog_87a824440101bqcl.html
Weather.h 文件
#import <UIKit/UIKit.h>
@interface Weather : UIViewController<CLLocationManagerDelegat
}
@property (assign) CLLocationManager *lma;
@property (nonatomic,retain)
@property (nonatomic,retain)
@property (nonatomic,retain)
#import "Weather.h"
@implementation Weather
@synthesize lma;
@synthesize getCurrentElement;
@synthesize Dic_weathForecast;
@synthesize getwoeidValue;
#define URL_FORECAST @"http://xml.weather.yahoo.com/forecastrss?w=%@&u=%@"
//以前的版本用:
//#define URL_LOCATION @"http://where.yahooapis.com/geocode?location=%f+%f&gflags=R&appid=yourappid"
}
- (void)xmlReadConnect
{
//被注释的部分,是之前的版本
//(2013-4-17改成这样了)改动之后注意:首先你要启动你的GPS,获取你所在地的经纬度,如果经纬度获取成功之后,然后通过经纬度获取woeid,之前的方法现在用不了了,现在yahoo通过经纬度获取woeid的方法改了,需要用yql来获取,yql的使用可以参考yahoo的yql用法。
//这里只能用插图了,不好意思,因为新浪博客会拦截URL编码
}
- (void)viewDidLoad
{
[self
[self
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
}
- (void)connection:(NSURLConnection *)connection didCancelAuthenticationC
{
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
}
- (void)connection:(NSURLConnection *)connection didReceiveAuthentication
{
}
- (void)connection:(NSURLConnection *)connection willSendRequestForAuthen
{
}
- (void)connectionDidFinishLoadi
{
}
bool flagNow = YES;
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString*)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
NSLog(@"currentWeatherValue
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString*)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString*)string
{
}
@end
//内存泄漏问题大家自己改了,我只提高实现获取yahoo天气方法