2

I created a list with the ability to delete lines by the method: .onDelete (perform:).

List { ForEach(itemList.dataLocation) { item in NavigationLink(destination: ListDetails(name: item.nameDB)) { ListItem(name: item.nameDB) } } .onDelete(perform: delete) .onMove(perform: move) } func delete(at offsets: IndexSet) { itemList.dataLocation.remove(atOffsets: offsets) session.deleteData(id: //id row) //this problem } 

How to pass the value of a deleted string to a function? It is advisable to still get data from this row. Thanks in advance!

1
  • if not mistake the IndexSet has got property that return first row Commented Nov 22, 2019 at 10:03

1 Answer 1

6

In the delete function offsets is an IndexSet of the items that got deleted. Normally it would be a set of one element.

func delete(at offsets: IndexSet) { for index in offsets { session.deleteData(id: itemList.dataLocation[index].id) // problem solved } itemList.dataLocation.remove(atOffsets: offsets) } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.