比如在开发时建了一个plist文件(字典数组):
let plistPath = Bundle.main.path(forResource: "appData", ofType: "plist")
//获取属性列表文件中的全部数据
let array = NSMutableArray(contentsOfFile: plistPath!)
for item in array! {
let dict = item as! NSDictionary
var name2 = "修改后的name"
var url2 = "修改后的url"
dict.setValue(name2, forKey: "app_name")
dict.setValue(url2, forKey: "app_url")
array?.write(toFile: plistPath!, atomically: true)
}
//输出修改后的plist文件
let x2 = NSMutableArray(contentsOfFile: plistPath!)