Re: How to override properties
Re: How to override properties
- Subject: Re: How to override properties
- From: Quincey Morris <email@hidden>
- Date: Thu, 01 Oct 2015 22:40:18 -0700
- Feedback-id: 167118m:167118agrif8a:167118sDgICtPJYh:SMTPCORP
On Oct 1, 2015, at 22:18 , Graham Cox <email@hidden> wrote:
>
> It’s not really about making the compiler happy, it’s about making your code clear and bug-free.
> The compiler is telling you your design is probably faulty, but the correct solution depends on your true intentions. What are they? You’ve slightly obfuscated the problem using pseudocode, so there’s no way to tell what’s the correct solution unless more info is provided.
I agree with what you say, but there is a bigger pitfall to avoid. If the subclass provides a second implementation of ‘stuff’, then it also provides a second ‘stuff’ instance variable. That probably causes BaseThing to break horribly — if it ever refers to its own instance variable directly. Is that likely to happen? Of course. Recommended practice is for a class to refer to the instance variable in its init methods, instead of using the corresponding property.
If the intention is merely to change the ‘stuff’ return type in the subclass, then @dynamic is the correct way to go. If the intention is to have two property implementations, then the subclass ‘stuff’ should be called something else.
_______________________________________________
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