title: Defining and using protocols in objective-c
body: <p>I'm trying to extend NSImageView so I can delegate the drag/drop responsibility to the controller. It all works fine with the one problem that the compiler is now displaying warnings about sending messages to objects with type id. To solve this I assumed I would simply have to suffix the ivar's type with the name of the protocol. However, this fails miserably with the message that it cannot find the definition for the protocol.</p>
  
  <pre><code>#import &lt;Cocoa/Cocoa.h&gt;
  
  
  @interface DragDropImageView : NSImageView {
      id &lt;DragDropImageViewDelegate&gt; _delegate;
  }
  
  @property (readwrite, retain) id &lt;DragDropImageViewDelegate&gt; delegate;
  
  @end
  
  @protocol DragDropImageViewDelegate
  
  @optional
  
  - (NSDragOperation)dragDropImageView:(DragDropImageView *)ddiv validateDrop:(id     &lt;NSDraggingInfo&gt;)info;
  - (BOOL)dragDropImageView:(DragDropImageView *)ddiv acceptDrop:(id &lt;NSDraggingInfo&gt;)info;
  - (void)concludeDragOperation:(id &lt;NSDraggingInfo&gt;)sender;  
  
  @end
  </code></pre>
  
  <p>Any pointers where I might be going wrong? I'm sure it must be something simple, but I'm quite new to obj-c.</p>