下载
2016-02-25 17:02
204 查看
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];
相关文章推荐
- C#生成图形验证码
- 数据库范式
- Valid Palindrome
- Pavilion M4-1016TX 加装固态硬盘(SSD)+UEFI+GPT安装WIN8.1
- iOS 移除所有子视图
- 字符串搜索算法总结
- 运行时runtime
- 极光推送的使用步骤
- 我理解的三个范式
- PHP基础
- HTTP协议(一):介绍
- struts2导出excel笔记
- Matlab中的静态(持久)变量和全局变量
- Objective-C中,遍历数组的四种方法
- HTTP协议初探
- as3 反向for循环测试总结
- shell获取 linux 系统的位数
- java中设置虚拟机最大内存
- iOS开发之提交App前需要准备的材料
- CGRidCtrl控件 学习心得