@AppStorage
was introduced in SwiftUI recently, it seems like an alternative to UserDefaults
.
I'm trying to make the @AppStorage
able to store nested lists.
For simple cases, you would do
@AppStorage("selected") var selected = 0
I used this while dealing with normal UserDefaults:
@Published var list = UserDefaults.standard.array(forKey: "nestedList") as? [[String]] ?? [[String]]()
Long story short, how do I convert plain old UserDefuaults
to the new property wrapper, @AppStorage
?