• 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: "Arthur C." <email@hidden>
  • Date: Tue, 17 Jul 2007 21:06:58 +0200

You should go back and (re)read Ben's post.

Okay, thanks. I missed that thread, which runs parallel to mine. For completeness, the link:
<http://www.cocoabuilder.com/archive/message/cocoa/2007/7/15/186219>


-didChangeValueForKey: is going to be sent anytime a key changes in pointer equality. This includes firing faults and undo. In neither case should the modification date be bumped.

More specific, the modification date has to return to its old value whenever a change is undone (well, you could argue about that, but at least that would be compatible with Apple's choice. When you edit a text file in TextEdit, and undo the changes, the file is clean again, i.e. does not have to be saved).


To include correct behaviour on undo, the code is updated as follows:

- (void) didChangeValueForKey: (NSString *) thisKey
{
[super didChangeValueForKey: thisKey];
if( ( [thisKey isEqualToString:@"modificationDate"] == NO) && ([self isFault] == NO) && ([[[self managedObjectContext] undoManager] isUndoing] == NO) && (startUpFinished == YES))
{
[self setModificationDate: [NSDate date]];
}
}


Using [self setPrimitiveValue:[NSDate date] forKey:@"modificationDate"]; as suggested by Ben, does not give correct behaviour, as the modification date is not updated on screen (no will/did change notifications, so the binding is not triggered...).

The [self isFault] condition will not help me get rid of the startUpFinished flag.

I'm currently using the most precise and most inconvenient method of maintaining the modification dates.

Putting a setModificationDate call in every setter, yes... but that was the reason I started this thread, to find a solution with less / better code. It's surprisingly hard to implement this (obvious) feature in a 'convenient' way...


Best regards,

Arthur C.

Jim

_________________________________________________________________
FREE pop-up blocking with the new Windows Live Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/


_______________________________________________

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


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

  • Prev by Date: NSNumberFormatter and 10.4 behavior
  • Next by Date: Re: How to keep creation/modification date of a (Core Data) object?
  • 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