• 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: Tony Becker <email@hidden>
  • Date: Sun, 15 Jul 2007 19:15:15 -0400

If it's faulting, then:
	[self isFault]

if it's undoing, then:
	[[[self managedObjectContext] undoManager] isUndoing]

will tell you. i.e.: there are ways to know. I don't know what your needs are for the modification date, so I don't know if you need to add them to the conditional or not.


On Jul 15, 2007, at 3:26 PM, Jim Correia wrote:

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

Tony Becker Cell: 727 460 1891

Never be afraid to try something new.
Remember that the ark was built by amatures and the Titanic was built by professionals.


_______________________________________________

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>)
 >Re: How to keep creation/modification date of a (Core Data) object? (From: Jim Correia <email@hidden>)

  • Prev by Date: Re: Request for help in getting table View to reflect fetch results
  • Next by Date: Strange KVC/KVO notification failure
  • 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