plist的读取和写入

时间:2023-03-10 06:40:08
plist的读取和写入
         // 从plist中读取数组数据
let arrPath = Bundle.main.path(forResource: "ArrayPList", ofType: "plist")!
let arr = NSArray(contentsOfFile: arrPath)! // 数组 写入 plist文件
arr.write(toFile: "/Users/yaoshuai/Desktop/ArrP.plist", atomically: true) // 从plist中读取字典数据
let dictPath = Bundle.main.path(forResource: "DictPList.plist", ofType: nil)!
let dict = NSDictionary(contentsOfFile: dictPath)! // 字典 写入 plist文件
dict.write(toFile: "/Users/yaoshuai/Desktop/DictP.plist", atomically: true)