Hey guys, I've got an interesting question for you. I've got a "last modified" attribute on all the objects stored in my data model, as I'm attempting to build a synchronization engine for the first time.
There's a method at the top-level of my data model abstraction, "modify", which updates the last modified timestamp to the current time.
But, all of my values are stored as properties, and there are *lots* of them. One way to go about this would be to manually implement *all* of the setters, changing something from:
To something like:
But rather than doing that for all my properties, it would be great if I could do something like: (pseudo-ish)
Hope that makes sense! Is there any easy way to do this?
There's a method at the top-level of my data model abstraction, "modify", which updates the last modified timestamp to the current time.
But, all of my values are stored as properties, and there are *lots* of them. One way to go about this would be to manually implement *all* of the setters, changing something from:
Code:
- (void)setTitle:(NSString *)newTitle {
if (newTitle != title) {
[title release];
title = [newTitle retain];
}
}
To something like:
Code:
- (void)setTitle:(NSString *)newTitle {
if (newTitle != title) {
[title release];
title = [newTitle retain];
[self modify];
}
}
But rather than doing that for all my properties, it would be great if I could do something like: (pseudo-ish)
Code:
- (void)propertyValueWillChange:(NSString *)propertyName toValue:(id)newValue {
[super propertyValueWillChange:propertyName toValue:newValue];
[self modify];
}
Hope that makes sense! Is there any easy way to do this?