谷歌新闻RSS提要返回一个didFailWithError语言 - 1002代码



我正在下载谷歌新闻作为RSS源。如果我在浏览器中查看,一切正常。但是,当我尝试使用以下代码下载可读文件时,我得到一个"-1002"错误。什么好主意吗?

- (void)viewDidLoad{
[super viewDidLoad];

path = @"feed://news.google.com/news?pz=1&jfkl=true&cf=all&ned=us&hl=en&q=oslo&cf=all&output=rss";
urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString: path]];
urlConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
[urlConnection release];

}
#pragma mark Download RSS
// Start connection and download
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
NSLog(@"didReceiveResponse");
rssData = [[NSMutableData data] retain];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)dataDownloaded {
NSLog(@"didReceiveData");
[rssData appendData:dataDownloaded];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSString * errorString = [NSString stringWithFormat:@"Error code %i", [error code]];
NSLog(@"error: %@", errorString);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSLog(@"connectionDidFinishLoading");
}

把feed://改成http://就可以了

最新更新