|
struct OneToManyCandyView: View { @Environment(.managedObjectContext) var moc @FetchRequest(sortDescriptors: []) var countries: FetchedResults<Country>
} |
|
hi mrad, to delete from the sectioned list by swiping, attach this
and then add the function
hope that helps, DMG |
|
|
|
Hi @delawaremathguy, I know this is many months later but I am asking in hopes that you might see this and help me. I've been trying to take your solution above and adapt it to work with a
The problem I have been running into is trying to figure out how to get the So how could I find the Thanks |
|
The .onTapGesture should provide the candy entity for the row tapped. Offsets are provided by the .onDelete modifier and aren't available/provided by .onTapGesture. I think - but haven't verfied - adding this to the .onTapGesture should do the trick... moc.delete(candy) try? moc.save() |
|
Sadly this won't work, and its because the data of the ForEach loop is coming from
|
|
So I have created a janky modified func from Chat-GPT which creates an somewhat solution and I am not entirely confident its actually deleteing anything.
It will "delete" and save but there is no animation and I honestly believe there has to be a more elegant way that will make swiftui more happy Edit: I have got the animation to work and that is by using |
SPONSORED Alex is the iOS & Mac developer’s ultimate AI assistant. It integrates with Xcode, offering a best-in-class Swift coding agent. Generate modern SwiftUI from images. Fast-apply suggestions from Claude 3.5 Sonnet, o3-mini, and DeepSeek R1. Autofix Swift 6 errors and warnings. And so much more. Start your 7-day free trial today!
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.