title: NSManagedObject with Category and Delegate
body: <p>I created a <code>NSManagedObject</code> called MapState.  I then created a category for it to call some methods and store some extra variables.</p>
  
  <p>.h
      #import "MapStateDB.h"</p>
  
  <pre><code>@protocol MapStateDelegate;
  
  @interface MapStateDB (MapState)
  
  @property (weak, nonatomic) id &lt;MapStateDelegate&gt; delegate;
  
  -(void)selectedSceneObject:(SceneObject *)sceneObject;
  -(void)removeDisplayedScene;
  
  @end
  
  
  @protocol MapStateDelegate &lt;NSObject&gt;
  
  -(void)displayScene:(SceneDB *)scene inState:(NSString *)state;
  -(void)removeScene:(SceneDB *)scene;
  
  @end
  </code></pre>
  
  <p>In the .m:</p>
  
  <pre><code>@dynamic delegate;
  
  -(void)setDelegate:(id&lt;MapStateDelegate&gt;)delegate {
  
  }
  </code></pre>
  
  <p>How do I do the setter?  Normally it would just be:</p>
  
  <pre><code>-(void)setDelegate:(id&lt;MapStateDelegate&gt;)delegate {
      _delegate = delegate;
  }
  </code></pre>
  
  <p>But since the variable is <code>@dynamic</code> instead of <code>@synthesize</code>, no <code>_delegate</code> is created. And <code>@synthesize</code> creates an error.</p>
  
  <p>How should I be handling this?</p>