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