plist文件的归档,解档
2016-05-20 18:18
351 查看
plist文件
plist的根Type只能是字典(NSDictionary)或者是数组(NSArray)所以归档时我们只能将数组或字典保存到plist文件中,但是NSString也能通过归档保存到plist文件中同时它也可以通过stringWithContentsOfFile解档,它保存到plist中时Type是空的,Value是有值的!
plist文件的归档
plist文件的解档
文/MelodyZhy(简书作者)
原文链接:http://www.jianshu.com/p/cd475693e2f8
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
plist的根Type只能是字典(NSDictionary)或者是数组(NSArray)所以归档时我们只能将数组或字典保存到plist文件中,但是NSString也能通过归档保存到plist文件中同时它也可以通过stringWithContentsOfFile解档,它保存到plist中时Type是空的,Value是有值的!
plist文件的归档
NSArray *arr = [[NSArray alloc] initWithObjects:@"1", @"2", nil]; // NSDocumentDirectory 要查找的文件 // NSUserDomainMask 代表从用户文件夹下找 // 在iOS中,只有一个目录跟传入的参数匹配,所以这个集合里面只有一个元素 NSString *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSString *filePath = [path stringByAppendingPathComponent:@"xxx.plist"]; [arr writeToFile:filePath atomically:YES];
plist文件的解档
NSString *filePath = [path stringByAppendingPathComponent:@"xxx.plist"]; // 解档 NSArray *arr = [NSArray arrayWithContentsOfFile:filePath]; NSLog(@"%@", arr);
文/MelodyZhy(简书作者)
原文链接:http://www.jianshu.com/p/cd475693e2f8
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
相关文章推荐
- 利用Core Dump调试程序
- mongodb(4查询)
- WCF Basics - FAQs Series【WCF基础----问答系列教程】
- html表单的各种输入控件
- mac出现clang error Undefined symbols for architecture x86_64
- php xml删除节点
- Android Service
- shell 字符串操作
- 欢迎使用CSDN-markdown编辑器
- LINUX下FTP相关命令
- oracle sql学习五
- HttpServletRequest——获取URL的方法
- 竞品分析报告怎么写
- Redis介绍以及安装(Linux)
- JADX使用下载
- Web安全相关(四):过多发布(Over Posting)
- JQuery 学习
- [Android5.1]Binder机制学习---Binder框架
- objc_setAssociatedObject、objc_getAssociatedObject、objc_removeAssociatedObjects
- Eclipse快捷键大全