How can I mutate inputted textField's String with binding action?? #3062
Unanswered
JongHoooon
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @JongHoooon, this is just a limitation of SwiftUI in general. If you were to recreate this app using either @Observable
class Model {
var text = "hello" {
didSet {
if text != text.lowercased() {
text = dump(text.lowercased())
}
}
}
}
struct A: View {
@Bindable var model = Model()
var body: some View {
Form {
TextField("", text: $model.text)
}
}
} I believe the way SwiftUI wants you to do these kinds of transformations is through formatters, which is an additional argument you can pass to |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hellow everyone!
My development eviroment
I want to muate inputted textField's String. ex) lowercased, trimmingCharacters, prefix...
I referenced Working with SwiftUI bindings
I tried three ways but not works😂
first try
second try
thrid try
I also referenced Performance
as I read sending actions is not lightweight so mutating inputted string every time looks not good.
Is there any good way mutating inpuuted string??
Beta Was this translation helpful? Give feedback.
All reactions