Re: How to keep creation/modification date of a (Core Data) object?
Re: How to keep creation/modification date of a (Core Data) object?
- Subject: Re: How to keep creation/modification date of a (Core Data) object?
- From: Tony Becker <email@hidden>
- Date: Wed, 11 Jul 2007 16:24:07 -0400
Ah! I think mmalc hit the nail on the head.
You want a transient modification date to update anytime an attribute
changes.
If so, trigger might not what you want - unless it's bound so that
the observing is set up - that's the key - the transient attribute
needs an observer on it to get the notification of the change from
the original attributes (KVO). Then, you can have an other method
pass back the modification time of the instance value.
Who ever recommended to override didChangeValueForKey: might be on
the right track too.
1) SubClass NSManagedObject and override didChangeValueForKey:
2) In the new didChangeValueForKey: method, check for [self
respondsToSelector:@selector(updateModificationDate)], and if so,
call it ([self updateModificationDate]) , and then call [super
didChangeValueForKey:]
3) For any class you want this to work, change it's parent to the new
subclass (from NSManagedObject) and add the updateModificationDate
method, which should update the transient modification time to
[NDDate date]
4) Create an accessor for the transient modification date, and use
that to know when the last peer (core data) attribute was changed.
if you need to be selective about which attributes cause modification
date to be updated, this won't work. You'll need to create accessors
(setters/getters) for each attribute and manually call the update
method.
On Jul 11, 2007, at 2:52 PM, mmalc crawford wrote:
On Jul 11, 2007, at 10:49 AM, Arthur C. wrote:
So why does the triggerChangeNotification have no effect? It just
doesn't work.
It behaves per the specification in the documentation:
"Configures the receiver to post change notifications for a given
property if any of the properties specified in a given array changes.
[...]
Invocations of will- and did-change KVO notification methods for
any key in keys will automatically invoke the corresponding change
notification methods for dependentKey. The dependentKey will not
receive willChange/didChange messages to generate the notifications."
It doesn't *change* the dependent key itself (typically the
dependent key is recalculated in its get accessor).
mmalc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Tony Becker
Cell: 727 460 1891
A good friend will come and bail you out of jail...
but, a true friend will be sitting next to you saying,
"Damn...that was fun!"--
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden