How do you make an Add Button that adds a Text? - Already Answered ✅

How do you make an add button that opens a sheet and there is a TextField that you can set to any text and when you press "Add" it will add the text that you put on the TextField and put it in the list.. I tried searching it up "How to make a button that adds a text in swiftUI" on google but the steps didnt work..
22 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
I already know that
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
like when your pressing a button it adds another button
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
what if the user is adding alot of buttons
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
but how do i make it, so that the user can set the label of the button and add it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
create the code
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
k
Hans
Hans2y ago
got it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
thx so do i add a @AppStorage() variable on the table so it will save? nvrmd theres another problem... How do you have multiple states in ForEach
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
like having 2 states in 1 foreach like when i try:
ForEach(sourcesTitleTable, sourcesDescTable, id: \.self) {sourcesProperties in
Text(sourcesProperties)

}
ForEach(sourcesTitleTable, sourcesDescTable, id: \.self) {sourcesProperties in
Text(sourcesProperties)

}
it doesnt work
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
lemme try it hmm theres an error so how do you fix it
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Hans
Hans2y ago
Hans
Hans2y ago
Buggy Technic nvrmd figured out how to have 2 tables in 1 forEach using the struct Identifiable thingy
Want results from more Discord servers?
Add your server