Here is a piece of my code for a games list view. If you select a game, you go to the second list view with players of the game. And then to a detail view about the players and the game combined. Also there are other views that need to reference the game. So I made the 'selected' game a EnvironmentObject var (which is an array with data). That way it is always available.
Since there is no need to pass 'game' to UserList, I removed it there so it's UserList().
Before the NavigationLink gets executed, I want to assign the selected game to selectedGame. How can I do that?
@EnvironmentObject var selectedGame : Game
...
List(games) { game in
NavigationLink(destination: UserList()) {
CellRow(game: game)
}
}