Storing Modified Dates - Core Data

Trent Jacobs <[email protected]>
Newsgroups gmane.comp.macosx.devel
Message-ID <[email protected]>
Hi all,

I have a core data application which synchronises data with an online  
service. Synchronisation needs to be done by comparing a 'modified  
date' field.

I thought I would be able to control the modified date field by doing  
the following in my base managed object class:

- (void) willSave
{
	NSDate *now = [NSDate date];
	if (false == [[self modifiedDate] isEqualToDate: now])
	{
		[self setPrimitiveValue:now forKey:@"modifiedDate"];
	}
}

This didn't work because the entity is saved whether it has been  
modified or not. So... short of adding a 'isDirty' flag, monitoring  
each setter and allowing for loading of models, is there a good way of  
doing this? I'l all out of ideas...

Thanks!
Trent.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.