views:

33

answers:

1

Hey,

I'm using CoreData in my application and depend on the NSManagedObjectContextObjectsDidChangeNotification. I have already subclassed NSManagedObject for all my Entities and created the properties and @dynamic accessors. Is it possible to exclude some properties of specific entities from the notification? If so, how would I do it? :-)

Thanks for helping!

A: 

You can't prevent the context change notification from firing for some attribute of some entity instance, but you can get information about the nature of the changes and respond to that instead.

Use [notification userInfo] to get a dictionary that contains lists of the changed objects based on the general type of change (inserted, updated, deleted). Example (pulled from this answer):

NSSet * deletedObjects = [userInfoDictionary objectForKey:NSDeletedObjectsKey];

You can then ask the managed objects for their -changedValues and take appropriate action if the keys of the returned dictionary contain (or don't) the interesting attribute keys.

Joshua Nozzi
thanks I'll do it this way!
porgi