Post

Replies

Boosts

Views

Activity

Reply to Fatal error: Index out of range: file Swift/ContiguousArrayBuffer.swift, line 444
The strings in array are updated by user input. You just need to manage deleted entries. Sorry I meant updated in general, I want to update the array when the user makes any change: editing, reordering, adding or removing elements. For that to work I'd have to track deletes somehow and think about how that might be impacted by inserts and reordering as well, which seems messy and introduces lots of potential problems. I found a thread on Stack Overflow - https://stackoverflow.com/questions/61434129/swiftui-deleting-last-row-in-foreach/61435489#61435489 which I think is closer to what I was hoping for, and so far appears to be working. ForEach (0..<array.count, id: \.self) { index in           TextEditor(text: Binding(  // << use proxy binding !!                 get: { array[index] },                 set: { array[index] = $0 }))         }         .onDelete { indexSet in            array.remove(atOffsets: indexSet)         }
Dec ’20