我正在将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");
}
答案 0 :(得分:1)
将feed://更改为http://并且它将起作用。