Q:

How do I include/retrieve/set the position of a body in a UserData struct?

I've managed to create a struct for UserData, but when I switch from using
ballBodyDef.userData = _ball;

to
MyBodyData *bodyData = new MyBodyData();
bodyData->someNumber = 4;
bodyData->sprite = _ball;
_body->SetUserData(bodyData);

the following fails:
for(b2Body *b = world->GetBodyList(); b; b=b->GetNext()) {    
    {
        if (b->GetUserData() != NULL)
        {
            CCSprite *myActor = (CCSprite*)b->GetUserData();
            myActor.position = CGPointMake(
                                           b->GetPosition().x * PTM_RATIO,
                                           b->GetPosition().y * PTM_RATIO );
            myActor.rotation = -1 * CC_RADIANS_TO_DEGREES(b->GetAngle());
        }
    }

I'm sure it has to do with the fact that the compiler cannot find/set the position of myActor, but I don't know how to include/retrieve/set the position of the body using a struct...

A:

 CCSprite *myActor = (CCSprite*)b->GetUserData();

You can't cast MyBodyData* to CCSprite*. You have to write:
if (b->GetUserData() != NULL)
{
    MyBodyData *data = static_cast<MyBodyData*>(b->GetUserData());
    //then retrive any info you need from data
}

