Hi everyone, I'm trying to initialize a view that uses a another struct. I want to pull that struct apart so that I can use those parts to fill in some TextFields with some already existing data, if it exists. Here is what my code looks like:
I get the error: "Cannot use instance member 'team' within property initializer; property initializers run before 'self' is available"
I want to eventually put these vars into TextFields like this, so users can edit it.
I'm not sure what I should do here. Could I get some help?
Code Block swift 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
I get the error: "Cannot use instance member 'team' within property initializer; property initializers run before 'self' is available"
Code Block swift TextField("Team Name", text: $name)
I want to eventually put these vars into TextFields like this, so users can edit it.
I'm not sure what I should do here. Could I get some help?