2011-07-22 49 views
0

我正在下載Google新聞作爲RSS訂閱源。如果我在瀏覽器中查看,一切工作正常。但是,當我嘗試使用以下代碼作爲可讀文件下載時,出現「-1002」錯誤。有任何想法嗎?Google新聞RSS訂閱返回a didFailWithError -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

更改提要://到http://,它會工作。

+0

太棒了。謝謝XcodeDev,像一個魅力:) – Jeremy