Thanks Jens and Peter, got it now.
All the Best
Dave
___
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubs
> On Jan 4, 2016, at 8:24 AM, Dave 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
Method return types are covariant though, yes? So you should always be able
to return a more-derived type from a method that is declared to return a
less-derived type. If I read your example right, ClassA is "Animal" and
ClassB is "Cat" (in covariance-blog-post lingo). So that is legal, unless
I'm
Hi Dave,
For myClassA, you will always have to cast the return value to myClassB
if you know that’s what will be returned. For a great blog post on the subject,
I give you Mike Ash:
https://mikeash.com/pyblog/friday-qa-2015-11-20-covariance-and-contravariance.html
Jeff Kelley
slaunch
Hi,
In Objective-C, is it possible to override a property and have it return a
different type to the base class?
I have a base class with the following property defined:
@property (nonatomic,retain)ClassA* propA;
and the following getter:
-(ClassA*) propA