From the course: Complete Guide to SwiftUI

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

List interaction

List interaction

- [Instructor] We have a lot of lists going on here. If your list is a dynamic one, like the order list, you can manipulate it with some modifiers. One of the most common of those is deleting an item on a list. So let's go over to OrderView and try this out. So we just go to OrderView. You can use modifiers like onDelete and onMove to move and delete your elements of your array. Both these have one requirement. It must be part of a ForEach embedded in a list. OrderView is not a list though, as if you go up to the top here, and if you remember, we are using a scroll view. So I'm going to go ahead and change this from a scroll view to a list to start this. And you get a white background saying that we're now in a list. Second thing we're going to do is we're going to have to put this onDelete after the ForEach So I'm going to actually just compress the ForEach for a moment and put right underneath here onDelete. And you got the onDelete(perform:) here. So I'm just going to do that, and…

Contents