vendredi 30 janvier 2015

Why does my code in my if statement not execute?

I have some code that first in the IBAction:



- (IBAction)LGrabCont:(id)sender {
if ([self.LGrab isSelectedForSegment:1]) {
if (LGrabState == FALSE) {
LGrabState = TRUE;
[self.output setString:[self.output.string stringByAppendingString:@"The left grabber is now open\n"]];
[self.output scrollToEndOfDocument:self];
}
} else if ([self.LGrab isSelectedForSegment:0]) {
if (LGrabState == TRUE) {
if (itemXPos == RealLArmX && itemYPos == RealLArmY && itemZPos == RealLArmZ && pickedUp == FALSE) {
[self.output setString:[self.output.string stringByAppendingString:@"You picked up an item!"]];
pickedUp = TRUE;
}
[self.output setString:[self.output.string stringByAppendingString:@"The left grabber is now closed\n"]];
[self.output scrollToEndOfDocument:self];
LGrabState = FALSE;

}
}
}


The variables with the prefix 'Real' are just variables that hold co-ord positions. RArm = Right arm LArm = Left arm. The problem is that when my 'Real' variables are correct and the GrabStates are set to true, the code in the



if ([self.LGrab isSelectedForSegment:0]) {
if (LGrabState == TRUE) {
if (itemXPos == RealLArmX && itemYPos == RealLArmY && itemZPos == RealLArmZ && pickedUp == FALSE) {
[self.output setString:[self.output.string stringByAppendingString:@"You picked up an item!"]];
pickedUp = TRUE;
}


Doesn't execute. Am I doing something wrong with my segmented view IBActions?


Aucun commentaire:

Enregistrer un commentaire