Re: Trouble comparing NSCalendarDates
Re: Trouble comparing NSCalendarDates
- Subject: Re: Trouble comparing NSCalendarDates
- From: j o a r <email@hidden>
- Date: Mon, 15 Nov 2004 10:32:32 +0100
On 2004-11-15, at 10.17, Tito Ciuro wrote:
2) Later, when I need to retrieve it from disk, I call returnedValue
= [[[NSCalendarDate alloc] dateWithCalendarFormat:dateData]
timeZone:nil]autorelease];
No, that's not right - what do you *really* call?
The data is retrieved from a SQLite database and is a 'const char*'.
So I call:
returnedValue = [[[NSCalendarDate alloc]
dateWithCalendarFormat:[NSString stringWithUTF8String:data]
timeZone:nil]autorelease];
What do you mean with "that's not right"? Why not?
* Always, and only, call an "initXXX" method on the returned value from
an alloc method. The init method used also needs to be one of the
documented designated initializers for the class!
* -[NSDate dateWithCalendarFormat:timeZone:] is an instance method of
NSDate, to convert a NSDate instance into a NSCalendarDate instance.
It's not a designated initializer for the NSCalendarDate class!
You should probably do:
NSString *dateStr = [NSString stringWithUTF8String: data];
NSCalendarDate *aDate = [NSCalendarDate dateWithString: dateStr
calendarFormat: nil];
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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