Error de tiempo de ejecución de retorno variable

I am making an iPhone app with cocos2d and Everytime I try to return a variable from a function I get a run time error on the code below...

     GB2ShapeCache *cache = [GB2ShapeCache sharedShapeCache];
    //EXC_BAD_ACCESS run time error here
    *eggFixture = [cache addFixturesToBody:body forShapeName:@"egg3"];

I don't know what I am doing wrong... here is the code for addFixturesToBody...

-(b2Fixture) addFixturesToBody:(b2Body*)body forShapeName:(NSString*)shape
{
    BodyDef *so = [shapeObjects objectForKey:shape];
    assert(so);
    b2Fixture *Fixi;
       FixtureDef *fix = so->fixtures;
    while(fix)
    {
        Fixi = body->CreateFixture(&fix->fixture);
        fix = fix->next;
    }

    return *Fixi;
}

and here I define my variable eggFixture

b2Fixture *eggFixture;

and here is where I try to use the b2fixture eggFixture later

for(pos = _contactListener->_contacts.begin(); 
        pos != _contactListener->_contacts.end(); ++pos) {
        MyContact contact = *pos;

        if ((contact.fixtureA == locations.platformFixture && contact.fixtureB == eggFixture) ||
            (contact.fixtureA == eggFixture && contact.fixtureB == locations.platformFixture)) {
            NSLog(@"Ball hit bottom!");
        }
    }

Any help? thankyou :)

preguntado el 10 de marzo de 12 a las 02:03

1 Respuestas

Parece body is nil. It will certainly crash here when body is nil:

Fixi = body->CreateFixture(&fix->fixture);

This article has some tips for debugging issues like EXC_BAD_ACCESS.

respondido 10 mar '12, 11:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.