Re: NSCalendarDate from CoreData
Re: NSCalendarDate from CoreData
- Subject: Re: NSCalendarDate from CoreData
- From: "Adam R. Maxwell" <email@hidden>
- Date: Tue, 28 Nov 2006 12:59:08 -0800
On Nov 28, 2006, at 12:51, Jim Thomason wrote:
I hope there's a more clever solution, but I'm just not finding it.
I have several dates in my CoreData store, and when I load them up, I
get back NSCFDate objects. But what I really want are NSCalendarDate
objects, so I can manipulate them more easily.
I get around this by copying it as such:
NSCalendarDate* realDate = [[NSCalendarDate alloc]
initWithString:[[myManagedThing valueForKey:@"myDate"] description]];
But this just seems...clunky to me.
Is there a slicker way? Or is this the way to go?
I'd use
NSTimeInterval time = [[myManagedThing valueForKey:@"myDate"]
timeIntervalSinceReferenceDate];
realDate = [[NSCalendarDate alloc]
initWithTimeIntervalSinceReferenceDate:time];
which avoids the date->string->date conversion.
-- Adam
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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