Categories
iOS Development

Quick tip: Avoid crash when using ForEach & Bindings in SwiftUI

If you’ve played around with ForEach and .onDelete in SwiftUI you might have encountered a crash due to ‘Index out of range‘ when you delete elements that are referenced with a binding (eg. a Toggle within your ForEach closure) This occurs due to a race condition of sorts… SwiftUI is trying to read from the […]