plist的读取和写入

 1         // 从plist中读取数组数据
 2         let arrPath = Bundle.main.path(forResource: "ArrayPList", ofType: "plist")!
 3         let arr = NSArray(contentsOfFile: arrPath)!
 4         
 5         // 数组 写入 plist文件
 6         arr.write(toFile: "/Users/yaoshuai/Desktop/ArrP.plist", atomically: true)
 7         
 8         
 9         // 从plist中读取字典数据
10         let dictPath = Bundle.main.path(forResource: "DictPList.plist", ofType: nil)!
11         let dict = NSDictionary(contentsOfFile: dictPath)!
12         
13         // 字典 写入 plist文件
14         dict.write(toFile: "/Users/yaoshuai/Desktop/DictP.plist", atomically: true)

 

posted @ 2017-01-05 13:15  ys123456789  阅读(246)  评论(0)    收藏  举报