Hello everyone,
I trying to draw a custom view inside a for each (list style), that is inside a Scroll View, that is inside a Navigation view. Like this.
Navigation View {
ScrollView {
ForEach(array of objects ...) {
CustomView()
}
}
}
The custom view calls up a sheet that has a button that is able to delete elements inside the collection used in the foreach.
Unless I use this asyncAfter after dismissing the sheet I always get index out of bounds when I try to remove the last element of the array of objects in the for each:
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
workouts.removeAll(where: { $0.id == workoutToRemoveID })
}
I have been trying to solve this bug, but so far no luck. Could you give me a hand?
Thank you for your help!