You will want to listen for the NSManagedObjectContextObjectsDidChangeNotification
to pick up all changes to your data model. This can be done using code like the following:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(handleDataModelChange:)
name:NSManagedObjectContextObjectsDidChangeNotification
object:myManagedObjectContext];
which will trigger -handleDataModelChange:
on any changes to the myManagedObjectContext
context.
Your -handleModelDataChange
: method would look something like this:
- (void)handleDataModelChange:(NSNotification *)note
{
NSSet *updatedObjects = [[note userInfo] objectForKey:NSUpdatedObjectsKey];
NSSet *deletedObjects = [[note userInfo] objectForKey:NSDeletedObjectsKey];
NSSet *insertedObjects = [[note userInfo] objectForKey:NSInsertedObjectsKey];
// Do something in response to this
}
As you can see, the notification contains information on which managed objects were updated, deleted, and inserted. From that information, you should be able to act in response to your data model changes.