Unable to write Swift Dictionary to NSUserDefaults in beta 5
I am working on an application where I use NSUserDefaults to save the Dictionary for use elsewhere in the program. This works great with Beta 1. Now with the latest update (Beta 5) this doesn't work anymore. It looks like they removed the ability to save a fast Dictionary this way. However, I can persist with NSDictionary. Here is a piece of code that worked 2 days ago and is now broken.
var userDefaults = NSUserDefaults.standardUserDefaults()
userDefaults.setObject(allPlayersDict, forKey: "playerDict")
userDefaults.synchronize()
This code does not write anything to NSUserDefaults, not even the key if set with:
var testDict = NSUserDefaults.standardUserDefaults().dictionaryRepresentation()
println(testDict)
Has anyone else experienced this or had a solution?
+3
source to share