How to work with [String] and [String]?
davidarice opened this issue · comments
davidarice commented
Is there a trick to getting this to work with an array? At the moment I simply using the following method:
var favorites: [String] { get { access(keyPath: \.favorites) return UserDefaults.standard.value(forKey: "favorites") as? [String] ?? [] } set { withMutation(keyPath: \.favorites) { UserDefaults.standard.set(newValue, forKey: "favorites") } } }
David Steppenbeck commented
Thanks for pointing that out. Fixed it, should now work with arrays and dictionaries.