hi Ben,
i've started to write a reply a few times and stopped, because i really don't see anything obviously amiss with your sectioning code.
i have used a similar setup, where the outer List is determined with a ForEach using a function of the @FetchRequest, and the function's return is either a 2-D array of items, or a 1-D array of custom structs (e.g., Array<SectionData>
, where SectionData
might have an id, the section's title, and the array of items for the section). i've not seen such a crazy animation for deletions before in either of these cases.
FWIW, i have had a constant struggle working with @FetchRequest and Core Data deletions, both when it comes to visual updates and the occasional crash with nil references to deleted Core Data objects. this happened even with a single section list.
so i have gone a slightly different route: i'll do a simple Core Data fetch() of all the items for the View and load them into a @Published array in an @ObservedObject (some sort of "viewModel") when the View comes on screen (usually, only the first time it comes on screen). then i do notifications when items are to be edited, added, or deleted; the viewModel picks up those notifications and makes an appropriate adjustment to its items array; and because this changes the items array, the View redraws using the viewModel's breakout of the items by section.
if you're interested in an example, take a look at my Shopping List project on Github. there are plenty of comments scattered around in the code to help folks understand what i did and why i did it.
hope that helps,
DMG