文件操作之plist文件读取
来源:互联网 发布:八进制转二进制算法 编辑:程序博客网 时间:2024/06/04 19:37
有时开发需要把一些信息用plist保存在本地
存写:
//获取应用沙盒的根目录
NSString *homePath =NSHomeDirectory();
//拼接路径
NSString *docPath = [homePathstringByAppendingPathComponent:@"Documents"];
//第二种方法
docPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)[0];
NSString *filePath = [docPathstringByAppendingPathComponent:@"toutiao.plist"];
NSArray *array =@[@"经纪人伟哥",@"经纪人洪",@"经纪人卓子",@"经纪人赵",@"经纪人白",@"孙宝强",@123,];
//将数组存储到文件中
[array writeToFile:filePathatomically:YES];
/Users/mfb/Library/Developer/CoreSimulator/Devices/2429D7D1-56FD-4BF4-BFBD-E61EE01B6D70/data/Containers/Data/Application/C53B4387-C51E-4636-8682-C21516DB1D5A/Documents/toutiao.plist
读取:
以存的类型为数组类型为例
//获取Documents目录
NSString *docPath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)[0];
//还要指定存储文件的文件名称,仍然使用字符串拼接
NSString *filePath = [docPathstringByAppendingPathComponent:@"toutiao.plist"];
//使用一个数组来接受数据
NSArray *array = [NSArrayarrayWithContentsOfFile:filePath];
Printing description of filePath:
/Users/mfb/Library/Developer/CoreSimulator/Devices/2429D7D1-56FD-4BF4-BFBD-E61EE01B6D70/data/Containers/Data/Application/C53B4387-C51E-4636-8682-C21516DB1D5A/Documents/toutiao.plist
Printing description of array:
<__NSCFArray 0x7fbeb1620d10>(
经纪人伟哥,
经纪人洪,
经纪人卓子,
经纪人赵,
经纪人白,
孙宝强,
123
)
- 文件操作之plist文件读取
- IOS Plist文件操作之写入/读取/删除
- 文件操作2之plist文件操作
- [数据存储之六]plist文件读取
- 读取plist文件
- IOS读取.plist文件
- NSArray 读取plist文件
- 读取plist文件
- OC读取plist文件
- 读取plist文件
- plist文件读取
- ios读取plist文件
- iOS -读取plist文件
- 读取plist文件
- plist文件读取
- cocos2d读取plist文件
- 数据存储之plist文件操作
- 数据存储之plist文件操作
- git 常用命令(含删除文件)
- LightOJ 1003 Drunk 拓扑排序判有向环
- html5 audio的暂停与播放
- RTC唤醒中断
- iOS解决导航栏标题向右偏移问题
- 文件操作之plist文件读取
- 多线程之初探
- 海思3519 sample困惑理解
- C# Bitmap rle格式解析
- 自定义dialog,留着以后备用
- iOS 的一些资源汇总
- git&github快捷命令以及笔记精华
- GPIO端口各种模式的区别
- Android为apk重新签名