-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Index out of bounds error after delete when using @ObservedSectionedResults in SwiftUI #8294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @GriffinMeyer Thanks for the reproduction app! I'm investigating this now. |
@GriffinMeyer could you check this PR out and see if it solves your issue? You will now need to use the .onDelete {
$todos.remove(atOffsets: $0, section: section)
} |
@leemaguire Yes! Problem fixed, and the deletions API is much cleaner! |
Any updates on getting this merged? |
@leemaguire |
@YevhenPryliepov looking into it now. |
Fixed in #8295 |
How frequently does the bug occur?
Always
Description
When using ObservedSectionedResults in SwiftUI, if you delete an item within a section, the app will crash with an index out of bounds error.
Stacktrace & log output
Can you reproduce the bug?
Always
Reproduction Steps
I've created a repo here: https://github.com/GriffinMeyer/section-list-delete-bug
Simply building and running the app, adding multiple Todos and then swiping to delete will cause the app to crash.
This also happens when using a synced realm, and the object is deleted from another source, so the issue is not specifically with the delete code.
Version
10.41.0
What Atlas Services are you using?
Atlas Device Sync
Are you using encryption?
No
Platform OS and version(s)
iOS 16.4, iOS 17
Build environment
Xcode version: 14.3.1
Dependency manager and version: SPM
The text was updated successfully, but these errors were encountered: