title: Navigation Link - Pass Specific Array Element To New View via NavigationLink & Lists
body: <p>I have an array titled <strong>recipeArray</strong> that is displayed in a list. When a list item is clicked, the user is taken to a new view titled <strong>RecipeItemDetailView</strong>. The array contains some default values as placeholders.</p>
  <pre><code>struct StoredRecipeModel: Identifiable {
  var id = UUID()
  var name: String
  var recipeSteps: [String]
  </code></pre>
  <p>}</p>
  <pre><code>struct ContentView: View {
  
  @State var recipeArray: [StoredRecipeModel] = [StoredRecipeModel(name: &quot;one&quot;, recipeSteps: [&quot;step1 here&quot;, &quot;step1b&quot;, &quot;Step1c&quot;]), StoredRecipeModel(name: &quot;two&quot;, recipeSteps: [&quot;step2here&quot;]), StoredRecipeModel(name: &quot;three&quot;, recipeSteps: [&quot;Step3here&quot;])]
  
  var body: some View {
      NavigationView {
              VStack {
                  List(recipeArray, id: \.id) { index in NavigationLink(destination: RecipeItemDetailView(recipe: $recipeArray, listItem: ListIndex.init())) {
                          HStack {
                              Text(index.name)
                              
                          }
                      }
                  }
  </code></pre>
  <p>In the <strong>RecipeItemDetailView</strong> (the view the user navigates to when clicking on a list item), I want to only display the data for a given element. For example, if the user clicks on the first item in the list (labeled &quot;One&quot;), I would only like to display the <strong>recipeSteps</strong> for that given element - in this case being [&quot;step1 here&quot;, &quot;step1b&quot;, &quot;Step1c&quot;].</p>
  <p>My current code passes forward the entire array. Is there a way to only pass forward the elements tied to a given index - e.g. the index that is clicked on?</p>
  <p><strong>EDIT - adding additional RecipeItemDetailView code</strong></p>
  <p>import SwiftUI</p>
  <p>struct RecipeItemDetailView: View {</p>
  <pre><code>@Binding var recipe: [StoredRecipeModel]
  @Environment(\.presentationMode) var presentationMode
  //@ObservedObject var listItem: ListIndex
  var recipeDataToReturn = 0
  
  
  var body: some View {
      
      var stored = [recipe[recipeDataToReturn].recipeSteps]
      
      NavigationView {
          VStack {
              List(stored[0], id: \.self) { index in Text(index)}
     
              List {
                  Section(header: Text(&quot;Section&quot;)) {
                      Button(&quot;print&quot;) {
                          print(stored)
                      }
                  }
              }
  
          }
      }
  }
  </code></pre>
  <p>}</p>