Multiple Documents, Core Data & NSFetchedResultsController
(too old to reply)
Sam Smallman
2018-06-07 05:36:36 UTC

I’m stuck in a bit of a rut here…
I have a macOS Document Based Application using Core Data.
Each document has its own Managed Object Context as created from the template NSPersistentDocument and is injected into the variety of model managers that need it throughout the app.

As a way of keeping track off all the changes and updating the UI I’m using NSFecthedResultsController and its delegate methods, particularly controller(_:didChange:at:for:newIndexPath:)

All works beautifully when a single document is open in terms of creating, editing and deleting managed objects.
The problem occurs when I have more than one document.
After creating a new object within one document, no other documents NSFetchedResultsController is notified of the change when an object is made in theirs.

I can confirm objects are being made with managedObjectContext.hasChanges
And check they are indeed the correct object with managedObjectContext.insertedObjects
And also interestingly when I add an observer for Notification.Name.NSManagedObjectContextObjectsDidChange I can log that change and see they are the correct object within the right context.
But for some reason, NSFecthedResultsController is not…

Would any of you have any clues I could chase down to figure this out.
Many thanks for your help in advance.



Cocoa-dev mailing list (Cocoa-***@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent t

Continue reading on narkive: