加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

objective-c – 如何使用NSURLDownload

发布时间:2020-12-16 10:16:33 所属栏目:百科 来源:网络整理
导读:- (IBAction)startDownloadingURL:(id)sender{ // create the request NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval
- (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的文档.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读