• 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: Subclassing/Override question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subclassing/Override question


  • Subject: Re: Subclassing/Override question
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 04 Jan 2016 17:49:29 -0800

> On Jan 4, 2016, at 8:24 AM, Dave <email@hidden> wrote:
>
> myClassB = myClassA.propA;			//Warning on this line saying return type is not ClassB

You have to declare the override in the subclass’s @interface, with the modified return type. Otherwise callers have no idea that your override exists or returns a different (more specific) class.

And as others have said, the override has to return a subclass of the inherited property, otherwise it’s not compatible. (The same goes for any method return type, not just a property, by the way.)

—Jens
_______________________________________________

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


  • Follow-Ups:
    • Re: Subclassing/Override question
      • From: Dave <email@hidden>
References: 
 >Subclassing/Override question (From: Dave <email@hidden>)

  • Prev by Date: making a pronunciation dictionary for Voiceover on the iphone
  • Next by Date: Re: Strange app crash
  • Previous by thread: Re: Subclassing/Override question
  • Next by thread: Re: Subclassing/Override question
  • Index(es):
    • Date
    • Thread