-
-
Save sturdysturge/63c8900adead1ed19d0f2b645fbc07e4 to your computer and use it in GitHub Desktop.
StaticStringConstants
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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