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: "Marcus S. Zarra" <email@hidden>
- Date: Wed, 11 Jul 2007 11:57:59 -0600
If this is a child class of a NSManagedObject you need to handle the
KVO notifiers yourself in the accessors:
- (void)setNewKey:(id)val {
[self willChangeValueForKey:@"newKey"];
...
[self didChangeValueForKey:@"newKey"];
}
- (id)newKey {
[self willAccessValueForKey:@"newKey"];
...
[self didAccessValueForKey:@"newKey"];
}
The reason for this is that the KVO notifiers are turned off in all
NSManagedObjects.
I came into this conversation late so if you have already done this I
apologize for the noise.
Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com
On Jul 11, 2007, at 11:49 AM, Arthur C. wrote:
I believe you need both set/getter methods to be KVC compliant,
and thus, for the dependent key trigger to work.
Watch for typo's and make sure the originalKey is also KVO
compliant (will/did change if Core Data)
+ (void) initialize {
[self setKeys:[NSArray arrayWithObject:@"originalKey"]
triggerChangeNotificationsForDependentKey:@"newKey"];
...
}
-(void)setNewKey:(id)val {
...
}
-(id)newKey {
...
}
Okay, but I have done that. Instance variable with setter and
getter, and no typos. Does it matter that I'm adding a variable/key
to a Core Data object? I don't want to include the extra variable
(modificationDateChanged or something) in the data model, as I
don't use it anywhere except for the triggerChangeNotification.
So why does the triggerChangeNotification have no effect? It just
doesn't work.
Thanks again,
Arthur C.
On Jul 9, 2007, at 1:23 PM, Arthur C. wrote:
On 08/07/07, Arthur C. <email@hidden> wrote:
This must be a simple use of setKeys:
triggerChangeNofiticationsForDependentKey, but I can't find
the right method
for the key 'modificationDate'...
Creation date is easy, just an awakeFromInsert will do.
But the modification date (obviously) has to change whenever
any of the keys
in the object changes. Moreover, it has to keep its value when
we are just
asking for the modification date (getter method), and on program
shutdown/restart.
_________________________________________________________________
Talk with your online friends with Messenger http://
www.join.msn.com/messenger/overview
_______________________________________________
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:
40zarrastudios.com
This email sent to email@hidden
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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