Backport of @AppStorage to earlier iOS 13. AppStorage is UserDefaults binder available in iOS14.
struct ContentView: View {
@AppStorage("username") var username: String = "Anonymous"
var body: some View {
VStack {
Text("Welcome, \(username)!")
Button("Log in") {
self.username = "@twostraws"
}
}
}
}
Add the following to your Xcode:
The project is available under MIT Licence