On 19 Nov 2010, at 14:38, Jonny Taylor wrote:

> I am encountering what I believe to be a spurious compiler warning. I wonder 
> whether this is a clue that I am doing something differently to how I 
> "should" do it. The problem comes if I define a protocol containing a 
> property and then define that property in a base class that does NOT conform 
> to the (whole) protocol. When I subclass that base class, I get warnings 
> about how the property is not defined.
> 
>       // I find myself writing "@dynamic genericProperty" here to shut up the 
> compiler warning
>       // that reads "warning: property 'genericProperty' requires method 
> '-genericProperty' to be defined - use @synthesize, @dynamic or provide a 
> method implementation"

It is my understanding that this is one of the reasons why @dynamic exists. 
i.e. I believe that you are already doing the Right Thing.

From the docs

"You use the @dynamic keyword to tell the compiler that you will fulfill the 
API contract implied by a property either by providing method implementations 
directly or at runtime using other mechanisms such as dynamic loading of code 
or dynamic method resolution.   It suppresses the warnings that the compiler 
would otherwise generate if it can’t find suitable implementations. You should 
only use it if you know that the methods will be available at runtime."

Well you know the method will exist at run time since you know your class is a 
subclass of a class that implements it.




_______________________________________________

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/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to