• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSCalendarDate from plist
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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 -----

  • Follow-Ups:
    • Re: NSCalendarDate from plist
      • From: Kurt Revis <email@hidden>
    • Casting (was: NSCalendarDate from plist)
      • From: Ondra Cada <email@hidden>
    • Re: NSCalendarDate from plist
      • From: Finlay Dobbie <email@hidden>
References: 
 >Re: NSCalendarDate from plist (From: Kurt Revis <email@hidden>)

  • Prev by Date: Re: NSString and gdb
  • Next by Date: Re: NSCalendarDate from plist
  • Previous by thread: Re: NSCalendarDate from plist
  • Next by thread: Re: NSCalendarDate from plist
  • Index(es):
    • Date
    • Thread