let plistPath = NSBundle.mainBundle().pathForResource("userConfig", ofType: "plist")
let dict = NSMutableDictionary(contentsOfFile: plistPath)
let data: (AnyObject!) = dict.objectForKey("baiduUrl")
var myDictionary: String = "http://www.baidu.com"
myDictionary.setObject(plistPath, forKey: "baiduUrl")
myDictionary.writeToFile(plistPath, atomically: false)
println(myDictionary)
Error : 'String' does not have a member named 'setObject'
更改编码。我无法更改 plist
最佳答案
您将 myDictionary 声明为字符串(并使用字符串文字对其进行初始化)。我很确定您打算将其声明为字典(给定名称)。字符串和字典不是一回事。
关于objective-c - Swift如何编写plist文件并更改值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25312365/