Re: NSCalendarDate from plist
Re: NSCalendarDate from plist
- Subject: Re: NSCalendarDate from plist
- From: "Erik M. Buck" <email@hidden>
- Date: Sun, 25 Nov 2001 14:36:37 -0600
Kurt Revis makes a very interesting observation about type casting that is
completely unwarranted.
calDate = [NSCalendarDate dateWithTimeIntervalSinceReferenceDate:[date
timeIntervalSinceReferenceDate]];
works just fine with no compiler warning because
+dateWithTimeIntervalSinceReferenceDate returns type id which is convertible
to any pointer to any object without any cast. The id type is one of
Objective-C's solutions to the "covariant" and "contravariant" issues. The
reason that methods such as -init and
+dateWithTimeIntervalSinceReferenceDate return id is so that they can be
overridden in subclasses to return instances of the subclass without type
issues.
Note to Objective-C newbies: If you ever find yourself casting the value
returned from a method to another object type, you are probably doing
something wrong.
----- Original Message -----