Xcode entero ++ sumando 4

Tengo un proyecto xcode que tiene el siguiente código:

en fflayer.h

int *ffinjar;

en fflayer.m

-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    CGPoint touchLocation = [self convertTouchtoNodeSpace:touch];
    CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
    oldTouchLocation = [CCDirector sharedDirector] convertToGL:oldLocation];
    oldTouchLocation = [self convertoToNodeSpace:oldTouchLocation];

    CGPoint translation = ccpSub(touchLocation, oldTouchLocation);
    [self panForTranslation:translation];

    if (CGRectIntersectsRect(selSprite.boundingBox, eJar.boundingBox)) {

    selSprite.userData = FALSE;
    selSprite.visible = FALSE;
    selSprite.position = ccp(winSize.width +40, winSize.height + 40);
    _currentFlies--;
    ffinjar++;

 }

por alguna razón, esto hace que ffinjar agregue 4 en lugar de 1. pero _currentFlies solo resta 1. No tengo idea. ¿alguien puede ver lo que puedo estar haciendo mal?

preguntado el 04 de julio de 12 a las 03:07

1 Respuestas

Es porque su declaración es de un puntero, e incrementar un puntero tiene una implicación diferente que incrementar un int (IIRC, se incrementa por tamaño de (int), por no estoy seguro).

int *ffinjar;
// perhaps should be
int ffinjar;

EDITAR: hice una prueba y, de hecho, incrementar un puntero a un int agrega 4 en mi sistema (y el tamaño de (int) también es 4)

Respondido 04 Jul 12, 03:07

Estás muerto. Muchas gracias. - user1415635

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