我想将数组保存到plist。因此,我已经写了上面这个功能。但是当我运行它时,我得到了上面的错误。
var tasks = [String]()
func addTask(name: String){
let path = NSBundle.mainBundle().pathForResource("Classes", ofType: "plist")
let dict = NSDictionary(contentsOfFile: path!)
dict?.setValue(name, forKey: "AppleDevice")
}
错误:
2015-09-12 21:37:52.383 SB Reminder[12433:2057713] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'
*** First throw call stack: