Saving CLLocation error: Mutating method sent to immutable object

限于喜欢 提交于 2019-12-07 17:57:31

You need to change the NSDictionary to an NSMutableDictionary.

var path = NSBundle.mainBundle().pathForResource("Config", ofType: "plist")
var plist: NSMutableDictionary = NSDictionary(contentsOfFile: path).mutableCopy() as NSMutableDictionary
plist.setValue(dataToStore, forKey: "location")

You can't call setValue on an NSDictionary as it is a mutating method and NSDictionary is immutable.

var plist = NSDictionary(contentsOfFile: NSBundle.mainBundle().pathForResource("Config", ofType: "plist"))

Change NSDictionary in this to NSMutableDictionary.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!