Google新闻RSS Feed返回didFailWithError -1002代码

时间:2011-07-22 22:33:49

标签: iphone sdk error-handling rss

我正在将Google新闻下载为RSS Feed。如果我在浏览器中查看,一切正常。但是当我尝试使用以下代码下载为可读文件时,我得到了一个" -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");

}

1 个答案:

答案 0 :(得分:1)

将feed://更改为http://并且它将起作用。