Skip to content
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

Using with NSFetchedResultsController #93

Open
grahamburgsma opened this issue Oct 22, 2018 · 1 comment
Open

Using with NSFetchedResultsController #93

grahamburgsma opened this issue Oct 22, 2018 · 1 comment

Comments

@grahamburgsma
Copy link
Contributor

I am trying to use Seam3 with an NSFetchedResultsController which uses the main viewContext (persistentContainer.viewContext). Unfortunately, any changes made by Seam3 from a sync aren't notifying the FRC delegate. I believe this is because the changes from the localStoreMOC aren't merged to the main viewContext as they should.

I tried finding the bug myself but I just started using CoreData a few weeks ago and am no expert, nothing I've tried has worked. If anyone could assist that would be great.

I understand I could use the SMStoreDidFinishSyncOperationNotification to update my UI instead of using NSFetchedResultsController, but using FRC is definitely the more efficient and preferred approach so I think this is a bug.

Would be happy to fix it myself if anyone can point me in the right direction. Thank you!

@grahamburgsma
Copy link
Contributor Author

Just discovered the original Seam project (https://github.com/nofelmahmood/Seam) handles this in the didFinishSyncing notification, seems like a good approach.

NSNotificationCenter.defaultCenter().addObserver(self, selector: "didFinishSyncing:",
                                                name: SMStoreDidFinishSyncingNotification,
                                                object: seamStore)
  
func didFinishSyncing(notification: NSNotification) {
  // Merge Changes into your context after syncing completes
  mainContext.mergeChangesFromStoreDidFinishSyncingNotification(notification)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant