- (IBAction)startDownloadingURL:(id)sender
{
// create the request
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
// create the connection with the request
// and start loading the data
NSURLDownload *theDownload=[[NSURLDownload alloc] initWithRequest:theRequest delegate:self];
if (!theDownload) {
// inform the user that the download could not be made
}
}当我运行模拟器时,我得到了一个错误:
NSURLDownload未声明,在此函数中首次使用。
在哪里可以导入NSURLDownload库。
发布于 2010-03-23 02:35:41
NSURLDownload不在iPhone上 见注:
iPhone OS注意: NSURLDownload类在iPhone操作系统中不可用,因为不鼓励直接下载到文件系统。使用NSURLConnection类代替。有关更多信息,请参见“使用NSURLConnection”。
看看苹果关于URL加载系统和NSURLDownload的文档。
发布于 2010-03-23 06:52:22
如果您只是想抓取页面的内容:
NSData *pageContents = [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.apple.com"]];https://stackoverflow.com/questions/2497149
复制相似问题