Why SwiftUI onDelete uses IndexSet?

Does any one know why onDelete method uses an IndexSet for delete operation? I couldn't find any way to delete more than one row from a List.

Replies

I understand it is to optimise (providing a range instead of list of individual values):

https://www.hackingwithswift.com/forums/swift/indexset-explained/2035

See also:

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

  • I understand this for onMove because you can actually move more than one row at the same time but onDelete always receives a range of one element.

Add a Comment