Re: How to override properties
Re: How to override properties
- Subject: Re: How to override properties
- From: Charles Srstka <email@hidden>
- Date: Thu, 01 Oct 2015 23:34:15 -0500
> On Oct 1, 2015, at 11:28 PM, Gerriet M. Denkmann <email@hidden> wrote:
>
> I inherited some code with:
>
> @interface BaseThing : NSObject <NSCopying>
>
> @property (nonatomic) SomeDataClass *stuff;
>
> @end
>
>
> @interface SubThing : BaseThing
>
> @property (nonatomic) SubDataClass* stuff; // SubDataClass is a subclass of SomeDataClass
>
> @end
>
>
> @implementation SubThing
>
> // nothing about stuff here
>
> @end
>
>
> Xcode 7.0 tells me:
> warning: auto property synthesis will not synthesize property ‘stuff’; it will be implemented by its superclass, use @dynamic to acknowledge intention.
>
> I don’t think that I want ’stuff’ to be implemented by its superclass. Rather I want it to be overridden. So I am not sure, whether @dynamic is the right thing to do.
>
> How to make the compiler happy?
Two options:
1) Implement -stuff and -setStuff: in your @implementation. If you do this, you don’t even need to declare stuff in the @interface.
2) Keep the declaration in the @interface, and stick “@synthesize stuff;” in the @implementation.
Charles
_______________________________________________
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