What am I missing...?
elsewhere in my project there is code like this:
let allUsers = ["userName":["difficulty": 1, "highscore": 50],"userName2":["difficulty": 2, "highscore: 75]]
defaults.setObject(allUsers, forKey: "allUsers")
I want to change a value for one user in that array of users:
var allUsers = defaults.objectForKey("allUsers") as! [String:NSMutableDictionary]
let changingUser = allUsers["userName"]! as NSMutableDictionary
Neither of these will work:
changingUser.setObject(3, forKey: "difficulty")
changingUser["difficulty"] = 3
with the error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'