• 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: Convenience Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convenience Methods


  • Subject: Re: Convenience Methods
  • From: Uli Kusterer <email@hidden>
  • Date: Wed, 26 Sep 2007 23:28:47 +0200

Am 26.09.2007 um 03:38 schrieb Nick Zitzmann:
You should always return an object of type id, so that the class method will work correctly with subclasses of the object.

Just to avoid confusion:

- It's a convention to have convenience methods declared with a return type of "id". I'm not sure why. If you declare your convenience method to return a MyObject*, and your subclass also uses the return type MyObject*, that's completely OK. Subclasses of MyObject are valid MyObjects, too.

- You *can not* return an *object* of type id, because id is an abstract type. There is no way to instantiate an id. This is mainly just terminology nitpicking, but maybe it saves some beginner a lot of time confusedly trying to come up with a way to instantiate an id...

Cheers,
-- M. Uli Kusterer
http://www.zathras.de



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Convenience Methods (From: Tim Davis <email@hidden>)
 >Re: Convenience Methods (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: how to build finalcut-pro style gui apps?
  • Next by Date: Re: Qustion about possibly bad advice in NSView documentation
  • Previous by thread: Re: Convenience Methods
  • Next by thread: Re: Convenience Methods
  • Index(es):
    • Date
    • Thread