Generating .onDelete on my list

I'm using a list with a navigation link in my swiftui app, and I'm not using a ForEach loop and trying to put the ".onDelete "method but I don't know how can I do that. Can you help me?

NavigationView {

      List(courses) {course in

        NavigationLink(destination: CourseDetails(course: course)) {

          StudentExtractedCourses(course: course)

        }

      }

    }

put it anywhere you wish it will be intercepted

You have to use ForEach. onDelete() modifier only exists on ForEach.

See this tutorial:

https://www.hackingwithswift.com/books/ios-swiftui/deleting-items-using-ondelete

Generating .onDelete on my list
 
 
Q