First, do not confuse objects and objects. Objects are abstractions related to classes, and they are never added or removed from the context of a managed object. These are managed objects that are added or removed from the context of a managed object. Each managed object is bound to an entity in a data model, just like any other instance of an object is bound to a specific class.
So, you really need to know when a managed object attached to a specific object is inserted / updated / deleted.
The easiest way to handle this is to register for context:
NSManagedObjectContextObjectsDidChangeNotification
... which will provide a notification whenever a managed entity in the context is inserted / updated / deleted. To find only managed objects that are bound to a specific object, check the objects returned by the NSInsertedObjectsKey, NSUpdatedObjectsKey, and NSDeletedObjectsKey keys, and then check the entity property for each object.
Alternatively, you use your own subclass of NSManagedObject and override awakeFromInsert to give a notification when an object is first inserted.
I would notice that such functionality is rarely needed. When you find that you are connecting a large number of notifications, this usually indicates that your data model needs to be processed to get more information. You usually need notifications because some key logic of the data model is not encoded in Core Data, but is in an external object that needs to be notified.
source share