I want to know how to add two Variables to a text field
Two Variables on a Text Field
Can you be more specific? What is Variable to a text field?
If you mean text parameter of a text field, there are no ways to have two.
Why don't you use two text fields?
If you mean text parameter of a text field, there are no ways to have two.
Why don't you use two text fields?
I want to add Scene Storage to the Text and a different variable here is some code I tried that did not work.
import SwiftUI
struct ContentView: View {
@SceneStorage("TextField") var textfield = ""
@State var Text = ""
var body: some View {
TextField("Placeholder", text: $textfield,
$Text)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
import SwiftUI
struct ContentView: View {
@SceneStorage("TextField") var textfield = ""
@State var Text = ""
var body: some View {
TextField("Placeholder", text: $textfield,
$Text)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
As I wrote, you cannot specify two bindings for text.
Better use only textfield and remove @State var Text = "".
By the way, please use Code block feature shown with an icon <> below the editing area.
Better use only textfield and remove @State var Text = "".
By the way, please use Code block feature shown with an icon <> below the editing area.
a textfield I'm talking about is one you type things in.
So what? Can you explain?a textfield I'm talking about is one you type things in.
I trying to figure out how to two variables to a textfield and telling a other guy what textfield I meant by.
Sorry, but it does not explain why you need two variables. You can use textfield instead of Text.I trying to figure out how to two variables to a textfield and telling a other guy what textfield I meant by.
I want to type something up and make appear somewhere else but I also want it to be saved with SceneStorage too. I'm a Beginner coder I need help.
You can use textfield instead of Text.I want to type something up and make appear somewhere else but I also want it to be saved with SceneStorage too.
There is a reason I want two variables in a textfield but just forget it.