mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
ListSectionOberserver not called on insert or delete #290
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @timfraedrich on GitHub (Oct 3, 2019).
CoreStore: 6.3.1
Swift: 5.1
Xcode: 11.0
Simulator: Xr iOS 13.0
I'm migrating all CoreData related code and models in my project to CoreStore right now, because it just seemed more convenient to me. But while replacing an NSFetchedResultsController with a sectioned list Monitor and ListSectionObserver I encountered the issue that the list does not get refreshed after an object is inserted, removed or dealt with in any other manner, because the functions of the Observer do not get called. That ultimately leads to the list being incomplete and wrong objects getting returned when clicking on a cell or - in the case of deletion - to a crash.
Here is the code I wrote:
I would greatly appreciate any help, maybe I'm just forgetting something really obvious.
@JohnEstropia commented on GitHub (Oct 3, 2019):
How does your transaction insert those objects? Can you show some code from the transactions side?
@timfraedrich commented on GitHub (Oct 3, 2019):
Yes of course:
I did try to insert it in other ways though (with unsafe and synchronous transactions) and that did not do anything different. The object is also there after I restart the app. The Observer is just not notified of a change.
@timfraedrich commented on GitHub (Oct 4, 2019):
Okay I found the solution: It turns out one should not blindly copy code from the documentation. It seems that it is not accurate anymore, since the NSIndexPath changed to IndexPath. The Observer now gets called with no issues.