Hi All,
I have this super simple code, where I want the userDefault to be set to a value and then displayed immediately.
The problem is that the UserDefault is set the SECOND time the view renders. So how can i fix this problem?
var body: some View {
VStack{
Text(UserDefaults.standard.string(forKey: "stringTester") ?? "Could not")
}.onAppear{
UserDefaults.standard.set("UserDefualt is not set", forKey: "stringTester")
}
}