Please try something like this:
import SwiftUI
struct HeartTextSquareView: View {
@State private var name: String = ""
@State private var adresse: String = ""
@State var telefonnummern: [String] = [] //<-
@State var something: String = ""
var body: some View {
VStack {
List {
TextField("Name/Vorname", text: $name)
TextField("Adresse", text: $adresse)
ForEach($telefonnummern, id: \.self) {$telefonnummer in
TextField("Telefonnummer", text: $telefonnummer)
}
Button(action: {
telefonnummern.append("")
}) {
Image(systemName: "plus.circle.fill")
.foregroundColor(Color(.systemGreen))
}
}
} //End VStack
}//End body
}//End `HeartTextSquareView`
When you want variable number of UI elements, you need to prepare a variable each element of which represents each UI element.