开发者

How to use NSURLDownload

开发者 https://www.devze.com 2022-12-24 20:14 出处:网络
- (IBAction)startDownloadingURL:(id)sender { // create the request NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@\"http://www.apple.com/index.html\"] cachePolicy:NSURLReq
- (IBAction)startDownloadingURL:(id)sender
{
    // create the request
    NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"] cachePolicy:NSURLRequ开发者_如何转开发estUseProtocolCachePolicy 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 got an error:

NSURLDownload undeclared, first use in this function.

Where can I import the library of NSURLDownload.


NSURLDownload not on iPhone see the note:

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.

Have a look at Apple's documentation about URL loading system and NSURLDownload.


If you've just looking to grab the contents of the page:

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号