如何使用NSURLDownload

mar*_*uca 3 iphone cocoa-touch objective-c nsurlconnection

- (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
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行模拟器时,我收到一个错误:

NSURLDownload unclared,首次使用此功能.

我在哪里可以导入NSURLDownload库.

ste*_*anB 10

NSURLDownload不在iPhone上看到说明:

iPhone OS注意:NSOSLDownload类在iPhone OS中不可用,因为不鼓励直接下载到文件系统.请改用NSURLConnection类.有关更多信息,请参阅"使用NSURLConnection".

查看Apple关于URL加载系统NSURLDownload的文档.