How to use NSURLD download

- (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
    }
}

When I run the simulator, I received an error message:

NSURLDDownload undeclared, first use this function.

Where can I import the NSURLDownload library.

+3
source share
2 answers

NSURLDDownload not on iPhone, see note:

iPhone OS Note: loading the NSURLD class is not available on iPhone OS as downloading directly to a file system is discouraged. Use NSURLConnection instead. See "Using NSURLConnection" for more information.

Apple URL NSURLDownload.

+10

:

NSData *pageContents = [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.apple.com"]];
+2

Source: https://habr.com/ru/post/1738120/


All Articles