title: 'Assigning to 'id' from incompatible type'
body: <p>I'm implementing a objective C wrapper for Box2d (which is written in c++). The b2Body keeps a reference to its wrapper B2Body in its userData field. GetUserData returns a void*. I'm now implementing fast iteration for getting the B2Bodies out of the B2World.</p>
  
  <p>I get an 'Assigning to 'id' from incompatible type 'B2Body *' error at the line indicated below. Why?</p>
  
  <pre><code>#import "B2Body.h"
  #import "B2World.h"
  #import "Box2d.h"
  
  @implementation B2World
  
  -(id) initWithGravity:(struct B2Vec2) g
  {
    if (self = [super init])
    {
      b2Vec2 *gPrim = (b2Vec2*)&amp;g;
      _world = new b2World(*gPrim);
    }
  
    return self;
  }
  
  - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len;
  
  {
    if(state-&gt;state == 0)
    {
      state-&gt;mutationsPtr = (unsigned long *)self;
      state-&gt;extra[0] = (long) ((b2World*)_world)-&gt;GetBodyList();
      state-&gt;state = 1;
    }
  
    // pull the box2d body out of extra[0]
    b2Body *b = (b2Body*)state-&gt;extra[0];
  
    // if it's nil then we're done enumerating, return 0 to end
    if(b == nil)
    {
      return nil;
    }
  
    // otherwise, point itemsPtr at the node's value
    state-&gt;itemsPtr = ((B2Body*)b-&gt;GetUserData()); // ERROR
    state-&gt;extra[0] = (long)b-&gt;GetNext();
  
    // we're returning exactly one item
    return 1;
  }
  </code></pre>
  
  <p>`</p>
  
  <p>B2Body.h looks like this:
      #import </p>
  
  <pre><code>@interface B2Body : NSObject
  {
    int f;
  }
  
  -(id) init;
  @end
  </code></pre>