• 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
DateCreated in CoreData - Best Method?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DateCreated in CoreData - Best Method?


  • Subject: DateCreated in CoreData - Best Method?
  • From: Steve Cronin <email@hidden>
  • Date: Sun, 12 Mar 2006 21:33:01 -0600

Folks;

I've got a CoreData entity for which I want to implement a 'dateCreated' field.
This entity will be slammed by an import process [potentially ~200K records per night).
So I want to be ABSOLUTELY certain I'm doing this as cleanly as possible.
[Not of course that I try do otherwise elsewhere but, ..... well, hopefully you get my drift]


So I've got 3 proposals in my brain:

1) - (void)awakeFromInsert {
   	NSDate *now = [NSDate date];
	[self setDateCreated:now];
	[self setDateLastModified:now];
________________________________________________
2) - (void)awakeFromInsert {
	[self setDateCreated:[NSDate date]];
	[self setDateLastModified:[NSDate date]];
________________________________________________
3) - (void)awakeFromInsert {
	[self setDateCreated:[NSDate] date];
	[self setDateLastModified:[self dateCreated]];
________________________________________________

1) This has the advantage of both attributes getting exactly the same value in all circumstances at the cost of initializing an instance variable and an NSDate class every time.

2) This has no instance variable but there are 2 NSDate class initializations and the values are not guaranteed to be exactly identical.

3) This has no instance variable and only 1 NSDate initialization and both values are guaranteed to be identical but has the overhead of [self ..].

I'm hoping knowledgeable folks might chime in on why one of these (or some other strategy) is distinctly better than the others. [stack management, compiler wisdom, autorelease behavior, messaging overhead, school of hard knocks...]

Thanks for any insights!
Steve

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: DateCreated in CoreData - Best Method?
      • From: Greg Herlihy <email@hidden>
  • Prev by Date: Re: Efficient way to composite large images?
  • Next by Date: Re: Efficient way to composite large images?
  • Previous by thread: Re: fetch request with compound predicate doesn't sort properly
  • Next by thread: Re: DateCreated in CoreData - Best Method?
  • Index(es):
    • Date
    • Thread