swift3.0 属性文件plist的应用
来源:互联网 发布:家庭网络覆盖 编辑:程序博客网 时间:2024/05/16 01:59
//获取工程中(私有的沙箱目录)" Data.plist "文件的路径
private varDataPlistPath: String! = Bundle.main.path(forResource: "Data", ofType: "plist")
private var localPlistPath: String! = NSHomeDirectory() + "/Documents/localData.plist"
//根据localPlistPath判断localData.plist文件是否存在
let dbexits = fileManager.fileExists(atPath: self.localPlistPath)
//如果文件不存在则创建localData.plist文件
fileManager.createFile(atPath: self.localPlistPath, contents: nil, attributes: nil)
}
//将字典类型的数据写入localData.plist
let rootDict = NSMutableDictionary()
//设置boolean
rootDict.setValue(true, forKey: "key_Boolean")
//设置array
rootDict.setValue(["one","two"], forKey: "key_Array")
//设置numberInt
rootDict.setValue(1, forKey: "key_Int")
//设置numberFloat
rootDict.setValue(1.2, forKey: "key_Float")
//设置dictionary
rootDict.setValue(["key1":"value1","key2":"value2"], forKey: "key_Dictionary")
//设置date
rootDict.setValue(NSDate(), forKey: "key_Date")
//将rootDict写入localData.plist文件
rootDict.write(toFile: self.localPlistPath, atomically: true)
//读取localData.plist里的数据
let rootDict = NSMutableDictionary(contentsOfFile: self.localPlistPath)
//若要修改数据,就修改读取到的rootDict,再把rootDict重新写入localData.plist
- swift3.0 属性文件plist的应用
- Swift3.0 info.plist文件访问权限汇总
- 应用的属性列表info.plist
- plist属性列表 文件的读写
- plist文件及UITableView的高级应用
- [绍棠_Swift] Swift3.0中如何获取Info.plist文件信息
- 修改工程的info.plist文件内属性
- cocos2d-x plist文件各个属性的含义
- Mac OS 的属性列表文件plist装换
- swift3.0 文件操作
- 应用plist文件制作 动画
- 苹果企业开发者应用plist文件的配置
- plist文件的读写
- plist文件的读写
- plist文件的读写
- plist文件的读写
- Plist文件的操作
- plist文件的读写
- Problem L. Canonical duel XVII Open Cup named after E.V. Pankratiev||并查集
- PHP 设计模式概述
- Java代码规范
- 2T架构师教学视频打包分享
- 关于下载JDK历史版本的一个可行方案
- swift3.0 属性文件plist的应用
- 【javascript】滚动条事件优化->函数节流与去抖
- (原创)cmake的编译命令提取过程
- 苹果IOS微信浏览器下自动播放音频问题+jquery click点击闪屏的问题
- 安卓屏幕完美适配方案
- 什么是长连接,什么是短连接?长连接和短连接的区别是什么?
- JuPyter Notebook中通过pip安装Python包(Module)
- MySQL root 用户丢失和密码重置
- Java servlet 之过滤器Filter详解