• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to keep creation/modification date of a (Core Data) object?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Michael Fey <email@hidden>
  • Date: Wed, 11 Jul 2007 14:06:17 -0400

Would overriding the - (void)didChangeValueForKey:(NSString *)key method of NSManagedObject do what you want?

We overrode it for one of our managed objects to set a date when the user enters some information about that object.

Regards,
	Michael Fey



On Jul 11, 2007, at 1:49 PM, 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:
40partech.com


This email sent to email@hidden

_______________________________________________

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


References: 
 >Re: How to keep creation/modification date of a (Core Data) object? (From: "Arthur C." <email@hidden>)

  • Prev by Date: Re: How to keep creation/modification date of a (Core Data) object?
  • Next by Date: fileDidClose Notification?
  • Previous by thread: Re: How to keep creation/modification date of a (Core Data) object?
  • Next by thread: Re: How to keep creation/modification date of a (Core Data) object?
  • Index(es):
    • Date
    • Thread