What’s the best way to serialize a Swift dictionary?
The problem that I am having is that using UserDefaults or NSKeyedArchiver is that key / pairs are not being updated, but replaced. In other words, I am unable to append new data then saving state.
Any suggestions would be appreciated, thank you.
Hi and welcome to the forum community @plemelle! What about using the set(_:forKey:) instance method? For example,
let defaults = UserDefaults.standard
let dictionary = ["Food": "Burger", "Type": "American"]
defaults.set(dict, forKey: "Popularity")
Thank you for the reply. Also, I was able to resolve the issue. Thanks again.
This topic was automatically closed after 166 days. New replies are no longer allowed.