• 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: Jim Correia <email@hidden>
  • Date: Sun, 15 Jul 2007 15:26:52 -0400

On Jul 15, 2007, at 3:17 PM, Arthur C. wrote:

I have found the following solution (thanks to your replies), which makes use of an override of the didChangeValueForKey method.

@implementation myManagedObject

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


Now that looks simple... However the small complication is that the modification date is also set when the program starts, as it calls the setters of the object to recreate the values it had before.

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

-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.

I'm currently using the most precise and most inconvenient method of maintaining the modification dates. (In part, because not all key changes should result in the logical change of the modification date - some are meta-values. YMMV.)

Jim

_______________________________________________

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: Tony Becker <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: Re: Request for help in getting table View to reflect fetch results
  • 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