Re: NSCalendarDate and +dateWithString:
Re: NSCalendarDate and +dateWithString:
- Subject: Re: NSCalendarDate and +dateWithString:
- From: Kyle Hammond <email@hidden>
- Date: Tue, 28 May 2002 12:16:53 -0500
Hi,
NSDate is toll-free bridged with CFDate. So the internal representation
of an NSDate class (or Cocoa subclass of NSDate) can also be passed to
the CFDate functions. An NSCalendarDate object created by
+dateWithString: DOES respond to the
-dateByAddingYear:months:days:hours:minutes:seconds: message and is also
a CFDate (or subclass). You don't need to worry about it's internal
implementation unless you're subclassing it or writing a developer tool.
Check the following URL and search for "toll-free" for more information
<
http://developer.apple.com/techpubs/macosx/ReleaseNotes/Foundation.html>
You could also try searching the email list archives at
<
http://cocoa.mamasam.com> because I know there have been previous
discussions of subclassing toll-free bridged class clusters such as
NSDate and NSString.
Hope that helps,
Kyle
On Tuesday, May 28, 2002, at 09:24 AM, email@hidden wrote:
Date: Tue, 28 May 2002 11:53:13 +0200
Subject: Re: NSCalendarDate and +dateWithString:
Cc: email@hidden
To: Nathan Day <email@hidden>
From: Malte Tancred <email@hidden>
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
---------------------
Kyle Hammond
http://www.CodeBlazer.com/ - multimedia software solutions
http://www.isd.net/dsl03002/ - my personal home page
_______________________________________________
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.