I've got an app design question that I'm hoping someone can help with.
Let's take a very simple setup: Core Data app for displaying news items from a server.
Main thread / UI has a managed object context that's used by all the view controllers to display the data.
An NSOperation runs in the background checking the server, with it's own context, on the same persistent store.
I want to merge the changes in the background context so I use NSManagedObjectContextObjectsDidChangeNotification.
Several system frameworks use Core Data internally. If you register to receive these notifications from all contexts (by passing nil as the object parameter to an addObserver… method), then you may receive unexpected notifications that are difficult to handle.
So, I want to filter my notifications merged in the main thread MOC to just those changes coming from the background operation MOC.
What's the cleanest way to get/maintain a reference to the background operation MOC so that I have something to plug into the addObserver method and the notifications are properly filtered? I can think of a lot of ways that involve a lot of coupling but they all seem like a hack.
Any suggestions or ideas? How are others handling this?