dkaisers
dkaisers

Reputation: 844

Check for changes in NSManagedObject's object graph

When working with NSManagedObjects, is there a way to know if the object itself or any of its referenced objects changed without having to iterate over all desired objects to check? If i call hasChanges or changedValues, those properties only reflect changes on the object itself, but not if any values in the objects referenced objects changed.

Upvotes: 0

Views: 132

Answers (1)

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46718

The easiest way is to listen for a notification. If you listen for NSManagedObjectContextObjectsDidChangeNotification you will receive a notification every time something has changed.

As you can guess, this is chatty.

You can also ask the NSManagedObjectContext for all objects that have changed and then filter through that array with a NSPredicate to check for the object you care about.

Upvotes: 2

Related Questions