图片缓存思路
来源:互联网 发布:数据库组成与原理五版 编辑:程序博客网 时间:2024/05/17 23:17
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; //生成plist文件 NSString *plistPath=[documentsDirectory stringByAppendingPathComponent:@"imageInfo.plist"]; NSFileManager* fm = [NSFileManager defaultManager]; [fm createFileAtPath:plistPath contents:nil attributes:nil]; //图片存储到沙盒中 NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"test.png"]; // 保存文件的路径 UIImage *myImage;//要存储的图片。。。 [UIImagePNGRepresentation(myImage) writeToFile: filePath atomically:YES]; //在plist中保存路径 NSMutableDictionary *dic = [[NSMutableDictionary alloc]init]; [dic setObject:filePath forKey:@"myimage"];//保存图片存储的路径到plist中 [dic writeToFile:plistPath atomically:YES]; //使用图片 NSDictionary* dic2 = [NSDictionary dictionaryWithContentsOfFile:plistPath]; //读取数据 if (dic2 == nil) { //1. 创建一个plist文件 NSFileManager* fm = [NSFileManager defaultManager]; [fm createFileAtPath:plistPath contents:nil attributes:nil]; }else{ UIImage *img = [UIImage imageWithContentsOfFile:[dic2 objectForKey:@"myimage"]]; }
1 0
- 图片缓存思路
- 图片缓存思路
- 图片缓存思路
- cell下载图片思路 – 无沙盒缓存
- LinkedHashMap数据结构分析,附带图片缓存思路
- android图片三级缓存的思路
- iOS开发-缓存图片到沙盒--思路
- 缓存思路
- Android三级图片缓存框架思路【附练习Demo】
- iOS缓存思路
- android 缓存思路
- 浏览器缓存解决思路
- 腾讯视频缓存思路
- 图片缓存
- 图片缓存
- 图片 缓存
- 图片缓存
- 图片缓存
- C实例---快速排序(冒泡排序)
- java学习笔记___数据类型
- PostgreSQL 逻辑结构 和 权限体系 介绍
- 汽车加油问题
- 即战力:如何成为世界通用的人才
- 图片缓存思路
- [操作系统] 添加加密文件系统,向/mnt写文件进程被杀死
- 频率域波图像增强
- Linux 进程间通信:信号量
- C++双冒号的作用
- SpringMVC和hibernate工作流程描述
- 动画用xml和Java代码之间的简单转换
- AAC 文件解析及解码流程
- 《项目管理利器Maven》学习(三):常用的maven命令介绍