project-imas / encrypted-core-data

v2.0 - iOS Core Data encrypted SQLite store using SQLCipher
Other
785 stars 236 forks source link

Duplicate objects returned by NSFetchedResultsController when updating subclassed entity after context save #253

Open rsaarloos opened 8 years ago

rsaarloos commented 8 years ago

Hi,

I'm having a strange problem with using the NSFetchedResultsController. I have a database setup like described http://martiancraft.com/blog/2015/03/core-data-stack/.

I have described a entity called A and a entity that subclasses A called B

I have a screen X that retrieves data and creates entities of type A and B. Then I have a screen Y that specifically retrieves data for entity B and updates entities of type B.

Screen X shows all entities of type A (so those also include the entities of type B) data using a NSFetchedResultsController and a UITableView. Screen Y shows all entities of type B using a NSFetchedResultsController and a UITableView.

The problem appears when: I first go to screen X, then persist the data (save the context), then go to screen Y and then go back to screen X. At this time the NSFetchedResultsController that drives the UITableView on screen X will show duplicate entries, namely the entries of type B that have been updated in screen Y are shown double.

So this only happens if the data is persisted and only seems to happen with encrypted core data, when switching to 'normal' NSSQLiteStoreType this error does not appear.

Anybody knows on how to resolve this?

lolgear commented 7 years ago

@rsaarloos possible that I am faced with the same issue.

I have abstract entity class A. It has two subclasses B:A and C:A.

And sometimes screen, that shows B and C together, shows copies of entities.