用于读写临时数据的方法
2010-09-02 09:35
225 查看
bool writeApplicationData(NSData *data, NSString *fileName) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; if (!documentsDirectory) { NSLog(@"Documents directory not found!"); return NO; } NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName]; return ([data writeToFile:appFile atomically:YES]); } NSData *applicationDataFromFile(NSString *fileName) { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *appFile = [documentsDirectory stringByAppendingPathComponent:fileName]; NSData *myData = [[[NSData alloc] initWithContentsOfFile:appFile] autorelease]; return myData; }
相关文章推荐
- iPhone官方SDK用于读写临时数据的方法
- 用于读写临时数据的方法
- iPhone官方SDK用于读写临时数据的方法
- iPhone读写临时数据方法
- android中JSON数据的读写方法
- [Android新手学习笔记08]-如何让活动Activity保存临时数据用于恢复
- 基于winform的二进制图片数据的存取(用于数据库照片的读写处理)
- R读写Excel文件中数据的方法
- StringIO 模块用于在内存缓冲区中读写数据
- NAND Flash 的数据读写方法及源程序
- Linux内核中读写文件数据的方法
- 不开辟用于交换数据的临时空间,完成字符串的逆序
- displaytag的使用方法(用于数据表格的显示和功能控制) tabledecorator实现链接按钮
- 当应用继承ContentProvider类,并重写该类用于提供数据和存储数据的方法,就可以向其他应用共享其数据。 虽然使用其他方法也可以对外共享数
- Nand Flash数据存储规则与数据读写方法(一)
- Linux内核中读写文件数据的方法
- Linux内核中读写文件数据的方法
- 不开辟用于交换数据的临时空间,如何完成字符串的逆序(在技术一轮面试中,有些面试官会这样问)
- 不开辟用于交换数据的临时空间,如何完成字符串的逆序
- 使用Mono Cecil 动态获取运行时数据 (Atribute形式 进行注入 用于写Log) [此文报考 xxx is declared in another module and needs to be imported的解决方法]-摘自网络