title: How do i pass the ForEach array index through a NavigationLink in to another ForEach without it crashing?
body: <p>I have this odd issue where it will work if i wait two seconds and press the NavigationLink but if i try to press it earlier than that it will crash the app, i am not sure what i am doing wrong. All i want to do is to get the array index from the first ForEach to use it for another ForEach loop.</p>
  <p>In the first struct i have declared these</p>
  <pre><code>@ObservedObject var vm = TripViewModel()
  </code></pre>
  <p>with the loop looking like this. I made sure to check with both print and a Text in the label that it actually get the array index, which it does.</p>
  <pre><code>                    ForEach(vm.TripData.indices, id: \.self) { trip in
                      
                      NavigationLink(
                          destination: TripView(tripCount: trip),
                          label: {
                              TableRow()
                              Text(&quot;\(trip)&quot;)
                          }
                      )
                      
                  }
  </code></pre>
  <p>And in the second struct, it has these declared</p>
  <pre><code>  @ObservedObject var vm = TripViewModel()
      var tripCount: Int = 0
  </code></pre>
  <p>with the ForEach relying on the previous loops index.</p>
  <pre><code>ForEach(vm.TripData[tripCount].Leg, id: \.self) { day in
  </code></pre>
  <p>It is right here that i get the crash error &quot;<strong>Thread 1: Fatal error: Index out of range</strong>&quot;</p>