Re: Subclassing/Override question
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