Post

Replies

Boosts

Views

Activity

Reply to Pulling apart a struct in another struct
Hey! Thanks for replying. struct Team {     var number: Int     var name: String     var players: [String]     var color: Color     var mascot: String    } struct TeamEditView: View {       var team: OlympicModel.Team       @Binding var isShowing: Bool   @State var name: String = team.name   @State var playersArray: [String] = team.players   @State var playerNameToAdd: String = ""   @State var color: Color = team.color   @State var mascot: String = team.mascot       var body: some View {     VStack(spacing: 0) {       ZStack {         Text("Edit Team").font(.headline).padding()         HStack {           Spacer()           Button(action: {             viewModel.updateTeam(teamNumber: team.number, OlympicModel.Team(number: team.number, name: name, players: playersArray, color: color, mascot: mascot))             self.isShowing = false           }, label: {Text("Done")}).padding()         }       }               Divider()       Form {         Section(header: Text("Event Details")) {           TextField("Team Name", text: $name)         }                 }     }         } } I plan on putting some more TextFields in the form to be able to create and then be able to edit a Team.
Oct ’20