- (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 undeclared, first use in this function.
在哪里导入NSURLDownload的库
最佳答案
NSURLDownload not on iPhone见注释:
iPhone OS Note: The NSURLDownload class is not available in iPhone OS as downloading directly to the file system is discouraged. Use the NSURLConnection class instead. See “Using NSURLConnection” for more information.
查看 Apple 关于 URL loading system 的文档和 NSURLDownload .
关于objective-c - 如何使用 NSURL 下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2497149/