Post not yet marked as solved
Post marked as unsolved with 4 replies, 2,036 views
I'm building a standalone WatchOS app. I have tried implementing the .onDelete modifier to easily delete items in a list, and I get no warnings or errors in XCode. But swiping, both in the simulator and Live Preview, does not do anything.
This is tested both in XCode 11.6 with WatchOS 6.2, and XCode 12.0 beta 2 with WatchOS 7.
Am I missing something here?
Minimal example:
struct ContentView: View {
@State var names = ["Alpha", "Bravo", "Charlie", "Delta"]
var body: some View {
ScrollView {
ForEach(names, id: \.self) { name in
Button(action: {}) {
Text(name)
}
}.onDelete(perform: deleteItems)
}
}
private func deleteItems(at offsets: IndexSet) {
names.remove(atOffsets: offsets)
}
}