Re: NSCalendarDate and +dateWithString:
Re: NSCalendarDate and +dateWithString:
- Subject: Re: NSCalendarDate and +dateWithString:
- From: Malte Tancred <email@hidden>
- Date: Tue, 28 May 2002 11:53:13 +0200
On tuesday, may 28, 2002, at 10:52 , Nathan Day wrote:
there is no reason that a method like dataWithString should return an
NSCalendarDate instance, NSCFDate is probable a subclass of
NSCalendarDate. Even the init methods do have to return an instance of
the type they are defined in.
Hmmm, I may have been a bit vague in my description of the problem. I'll
try to elaborate.
Init methods are instance methods. You send an init message to an
instance of a class. Class methods, like for example +dateWithString:,
are implemented by class objects. There's a huge difference between
sending messages to instances and classes.
I don't believe NSCFDate is a subclass of NSCalendarDate. If it were, an
instance of NSCFDate would respond to the message
dateByAddingYear:months:days:hours:minutes:seconds:, but it doesn't. I
believe NSCFDate is a private, concrete subclass of NSDate. I also
believe NSCFDate is one of these CF-Cocoa bridged objects, ie NSCFDate
is a CFDate.
But I may be mistaken. :-)
An NSDate represents an instant in time while NSCalendarDate represents
an instant in the gregorian calendar. NSCalendarDate inherits NSDate and
so responds to all methods declared in NSDate.
In the documentation for NSDate +dateWithString: refers to
-initWithString:, which in turn states that "This method uses the
designated initializer, initWithTimeIntervalSinceReferenceDate:."
This leads at least me, to presume that sending the message
dateWithString: to the class object NSCalendarDate would give me an
instance of NSCalendarDate, initialized with the time since reference
date that the passed in string represents (also using the default or
system time zone).
Perhaps I'm misreading the documentation, or have a funny way of looking
at OO design principles. I'm open for suggestions.
Thank you for your time.
Cheerio,
Malte
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.