I have a ForEach
block and a Stepper
embedded in a List
view. The contents of the List
view's first section is as follows:
ForEach(record.nodes.indices, id: \.self) { index in
HStack {
TextField("X", text: self.$record.nodes[index].xString)
Spacer()
Divider()
TextField("Y", text: self.$record.nodes[index].yString)
Spacer()
}
}
Stepper("± node", onIncrement: {
self.record.nodes.append(Node(x: 0, y: 0))
}, onDecrement: {
self.record.nodes.removeLast()
})
The issue I am facing is that upon calling self.record.nodes.removeLast()
, the application crashes with an Index out of range
error. I've been trying to solve this for hours, but to no avail.
I originally used onDelete
, however that produced the same issue.
The project can be found at https://github.com/jacobcxdev/Timekeeper, with this error happening in RecordDetailView.swift.