How to set change date every time when NSManagedObject changes?

Every time one of my managed objects changes, I want to save the date when it was changed (in an attribute that is already in my data model), for convenience, when I synchronize with other clients.

Is there a way to do this without A) rewriting all my setters manually or B) relying on myself to always change the modification date every time the object was changed?

+4
source share
2 answers

You can register in the notification center to view the NSManagedObjectContextObjectsDidChange notification.

This will tell you which objects are modified. You can check if your object is among them and take action accordingly.

+2
source

Just for completeness, you can also do this in -willSave if you already have a subclass of NSManagedObject.

0
source

All Articles