DateCreated in CoreData - Best Method?
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