-1

I am having real trouble here. I have a list that I am trying to add a new item to the list each time I add a new line of data to my data file however it is just showing the same data.

I have scoured the internet and even tried following the apple developer site.

Data

List Item

List View

  • you should share text. Not image. We can not copy-paste – Tolga Kağan Jun 02 '22 at 21:32
  • 1
    As said it's better if you share text instead of photos. Anyway, it is always showing the same item because in ListItem you are initializing it with item[0]. On the ListView 's ForEach loop you have to pass the item to the ListView constructor and use it instead of the item[0]. – CJ_COIMBRA Jun 02 '22 at 22:35

1 Answers1

1
struct ListItem: View {
     var item: VocabItem
      ...  
}

struct VocabList {
     .
     .
     .
       
       ForEach(items) { item in
           ListItem(item: item)
       }
}
Tolga Kağan
  • 143
  • 1
  • 11