iphone - Objective-C, protocols and subclasses -


let's have following protocols defined:

// basic protocol user interface object:

@protocol uiobjectprotocol <nsobject> @property (assign) bool touchable; @end 

// basic protocol user interface object held holder object:

@protocol uiheldobjectprotocol <uiobjectprotocol> @property (readonly) id holder; @end 

and following class hierarchy:

// base class user interface object, synthesizes touchable property

@interface uiobject : nsobject <uiobjectprotocol> {    bool _touchable; } @end  @implementation uiobject @synthesize touchable=_touchable; @end 

at point, ok. create uiobject subclass named uiplayingcard. inherently, uiplayingcard conforms uiobjectprotocol since it's superclass too.

now suppose want uiplayingcard conform uiheldobjectprotocol, following:

@interface uiplayingcard : uiobject <uiheldobjectprotocol> { } @end  @implementation uiplayingcard -(id)holder { return nil; } @end 

note uiplayingcard conforms uiheldobjectprotocol, transitively conforms uiobjectprotocol. i'm getting compiler warnings in uiplayingcard such that:

warning: property 'touchable' requires method '-touchable' defined - use @synthesize, @dynamic or provide method implementation

which means uiplayingcard superclass conformance uiobjectprotocol wasn't inherited (maybe because @synthesize directive declared in uiobject implementation scope).

am obligated re-declare @synthesize directive in uiplayingcard implementation ?

@implementation uiplayingcard @synthesize touchable=_touchable; // _touchable must protected attribute -(id)holder { return nil; } @end 

or there's way rid of compiler warning? result of bad design?

thanks in advance,

i'll throw in 1 other way silence warning: use @dynamic, , compiler assume implementation provided in other way in declaration in class's implementation (in case, it's provided superclass).


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -