title: How can I delete an item in a List ? SwiftUI
body: <p>I'm trying to edit a List (composed of mutable strings) with an edit button and a function. My code is:</p>
  <pre><code>struct annotationsView: View {
      
      
      @State private var text = &quot;&quot;
      //    annotations
      @State var annotations : [[AnnData]] = [[]]
      
      var body: some View {
          VStack{
              Form{
                  HStack{
                      TextField(&quot;Add your annotations here&quot;, text: $text)
                          .textFieldStyle(RoundedBorderTextFieldStyle())
                      
                      Button(&quot;Submit&quot;) {
                          annotations[annotations.count - 1].append(AnnData(Anntext: text))
                          self.hideKeyboard()
                          text = &quot;&quot;
                      }
                  }
                  List{
                      ForEach(annotations.indices, id:\.self){index in
                          
                          ForEach(annotations[index].indices, id:\.self){annotationIndex in
                              
                              Text(annotations[index][annotationIndex].Anntext)
                          }.onDelete(perform: self.deleteItem) //&lt;-- Here
                      }
                  }
                  
              }
          }
          .background(
              Image(&quot;Background&quot;)
                  .resizable()
                  .edgesIgnoringSafeArea(.all)
                  .navigationBarTitle(Text(&quot;Annotations&quot;), displayMode: .inline)
          )
          .navigationBarItems(trailing: EditButton())
      }
      
      private func deleteItem(at indexSet: IndexSet) {
          annotations.remove(atOffsets: indexSet)
      }
  }
  struct AnnData : Identifiable{
      
      var id = UUID().uuidString
      var Anntext: String
  }
  </code></pre>
  <p>Currently, I can not delete a single item; when I delete one, the rest are deleted automatilcally. Also, after that I can't add some items inside the List.
  Would you mind explaining what's wrong here?
  Thanks for your help!</p>