Store and update a Swift Dictionary in NSUserDefaults Xcode
I would like to store and update a Dictionary when a user enters a value. Everything seems to function until this code, and the application crashes: override func viewDidLoad() { super.viewDidLoad() if NSUserDefaults.standardUserDefaults().objectForKey("dict") != nil { answersSaved = NSUserDefaults.standardUserDefaults().objectForKey("dict") as [String:String] } } The error message says "anyObject is not convertible to [String:String]. It offers to add ! after the as but then the app crashes. dict is my Dictionary variable with Strings as values. I also have code updating the NSUserDefaults