Get modification date for NSManagedObject in Core Data?

No, you must add a date and manage it yourself. You can use override -willSave in your managed object to update the time stamp, but read the API documentation for NSManagedObject on -willSave for how to update without causing a willSave loop (the docs even talk about the case of updating a timestamp). The docs also mention using the NSManagedObjectContextWillSaveNotification, but that may be more trouble to set up than a simple check to not set the timestamp too quickly.


I personally check if updatedAt was modified, and if yes then I don't touch it anymore. This way I break the willSave loop.

- (void)awakeFromInsert {
    [super awakeFromInsert];

    self.primitiveUpdatedAt = [NSDate date];
}

- (void)willSave {
    [super willSave];

    if(![self isDeleted] && self.changedValues[@"updatedAt"] == nil) {
        self.updatedAt = [NSDate date];
    }
}