hwo to swipe to delete swiftui code example

Example 1: disable swipe to delete swift

override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
    if tableView.editing {
        return UITableViewCellEditingStyle.Delete
    }
    return UITableViewCellEditingStyle.None
}

Example 2: swipe right to delete swiftui

struct SingleIsland {
    let name: String
}

struct ContentView: View {

    @State var islands = [
        SingleIsland(name: "Wangerooge"),
        SingleIsland(name: "Spiekeroog"),
        SingleIsland(name: "Langeoog")
    ]

    var body: some View {
        List {
            ForEach(islands.identified(by: \.name)) { island in
                Text(island.name)
            }.onDelete(perform: delete)
        }
    }

    private func delete(with indexSet: IndexSet) {
        indexSet.forEach ({ index in 
        	islands.remove(at: index) 
        })
    }
}