Currently learning SwiftUI using the Scrumdinger tutorial and when finished stumbled into an issue: how to I delete each added scrum card? The idea is to remove not only from list but also from storage.
Thank you for your time!
Currently learning SwiftUI using the Scrumdinger tutorial and when finished stumbled into an issue: how to I delete each added scrum card? The idea is to remove not only from list but also from storage.
Thank you for your time!
Add .onDelete modifier:
struct ScrumsView: View {
@Binding var scrums: [DailyScrum]
@State private var isPresentingNewScrumView = false
@State private var newScrumData = DailyScrum.Data()
var body: some View {
List {
ForEach($scrums) { $scrum in
NavigationLink(destination: DetailView(scrum: $scrum)) {
CardView(scrum: scrum)
}
.listRowBackground(scrum.theme.mainColor)
} // <<-- ADD THE FOLLOWING
.onDelete { indices in
scrums.remove(atOffsets: indices)}
}