Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import SwiftUI
extension String {
static let nameKey = "nameKey"
static let ageKey = "ageKey"
struct ContentView: View {
@AppStorage(.nameKey) var name: String = ""
let age = UserDefaults.standard.integer(forKey: .ageKey)
var body: some View {
VStack {
Text("name: \(name)")
Text("age: \(age)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment