Simply composing @State @UserDefault
will not do what I want in the end .
@State @UserDefaulr(key: ..., defaultValue: "a string")
var property: T // <== T is a String
One of the use is with TextField("Field Name", text: $property)
or any other form widgets, for TextField
$property
is a Binding<String>, but it's a Binding<UserDefault<String>>. Anyway, the end goal is when TextField
or any other widgets make edit, the change is propagate back and persist to UserDefaults
. But just composing wrapper of a wrapper, the whole thing just doesn't work.
Can I subscribe to @State
change event? It must have publisher inside.