Let's say that I have the following protocols defined:
// basic protocol for an User Interface object:
@protocol UIObjectProtocol <NSObject>
@property (assign) BOOL touchable;
@end
// basic protocol for an User Interface object that is held by a holder object:
@protocol UIHeldObjectProtocol <UIObjectProtocol>
@property (readonly) id holder;
@end
And the following class hierarchy:
// base class for an User Interface object, which synthesizes the touchable property
@interface UIObject : NSObject <UIObjectProtocol> {
BOOL _touchable;
}
@end
@implementation UIObject
@synthesize touchable=_touchable;
@end
At this point, everything is OK. Then I create a UIObject subclass named UIPlayingCard. Inherently, UIPlayingCard conforms to the UIObjectProtocol since it's superclass does it too.
Now suppose I want UIPlayingCard to conform to UIHeldObjectProtocol, so I do the following:
@interface UIPlayingCard : UIObject <UIHeldObjectProtocol> {
}
@end
@implementation UIPlayingCard
-(id)holder { return Nil; }
@end
Note that the UIPlayingCard conforms to UIHeldObjectProtocol, which transitively conforms to UIObjectProtocol. However I'm getting compiler warnings in the UIPlayingCard such that:
warning: property 'touchable' requires method '-touchable' to be defined - use @synthesize, @dynamic or provide a method implementation
which means that the UIPlayingCard superclass conformance to the UIObjectProtocol wasn't inherited (maybe because the @synthesize directive was declared in the UIObject implementation scope).
Am I obligated to re-declare the @synthesize directive in the UIPlayingCard implementation ?
@implementation UIPlayingCard
@synthesize touchable=_touchable; // _touchable now must be a protected attribute
-(id)holder { return Nil; }
@end
Or there's another way to get rid of the compiler warning? Would it be the result of bad design?
Thanks in advance,