下载

23 篇文章 0 订阅
2. /Documents/。使用该路径放置关键数据,也就是不能通过App重新生成的数据。该路径可通过配置实现iTunes共享文件。可被iTunes备份。(现在保存在该路径下的文件还需要考虑iCloud同步)

3. /Library/。该路径下一般保存着用户配置文件。可创建子文件夹。可以用来放置您希望被备份但不希望被用户看到的数据。该路径下的文件夹,除Caches以外,都会被iTunes备份。

4. /tmp/。使用该路径保存临时文件。App应该删除那些不再被使用的文件,系统也会在App关闭后删除残留文件。该路径下的文件不会被iTunes备份。



NSArray* paths = NSSearchPathForDirectoriesInDomains(NSPicturesDirectory, NSUserDomainMask, YES);
    NSString* _filePath = [paths objectAtIndex:0];
    NSString *fileName = [NSString stringWithFormat:@"filename.pdf",];
    NSString *filePath = [_filePath stringByAppendingPathComponent:fileName];
NSString *urlStr =@"http://loadurlStr";
            NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
            AFURLConnectionOperation *operation = [[AFURLConnectionOperation alloc]initWithRequest:request];
            operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:YES];
            [operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
                NSLog(@"%f",totalBytesRead/(float)totalBytesExpectedToRead);
            }];
            [operation setCompletionBlock:^{
            //用webview打开下载下来的文件
                NSURL *url = [NSURL fileURLWithPath:filePath];
                NSURLRequest *request = [[NSURLRequest alloc]initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20];
                UIWebView *web = [[UIWebView alloc]initWithFrame:self.view.bounds];
                [self.view addSubview:web];
                [self.view bringSubviewToFront:web];
                [web loadRequest:request];
            }];
            [operation start];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值