Either or a bug or coding error.

Discussion in 'iOS Development' started by JoshuaCaputo, Dec 9, 2008.

  1. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    Code:
    	redString = redString+1;
    	if (redString == 1){
    			[redBall setImage:[UIImage imageNamed:@"yelBall.png"] forState:UIControlStateNormal];
    	}
    	if (redString == 2){
    		[redBall setImage:[UIImage imageNamed:@"greBall.png"] forState:UIControlStateNormal];
    	}
    	if (redString == 3){
    		redString = 1;
    		[redBall setImage:[UIImage imageNamed:@"bluBall.png"] forState:UIControlStateNormal];
    	}
    
    Every time I execute the action it just skips down to the bottom turning the image to bluBall.png rather than yelBall.png. I am pretty sure this is because the action is going fast and changing the intervals as they happen. How can I stop this or slow it down?
    ------------------double post merged------------------
    Got It!
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    Why not this

    Code:
    if (redString == 1){
    			[redBall setImage:[UIImage imageNamed:@"yelBall.png"] forState:UIControlStateNormal];
    	} else  if (redString == 2){
    		[redBall setImage:[UIImage imageNamed:@"greBall.png"] forState:UIControlStateNormal];
    	} else if (redString == 3){
    		redString = 1;
    		[redBall setImage:[UIImage imageNamed:@"bluBall.png"] forState:UIControlStateNormal];
    	} 
  3. JoshuaCaputo

    JoshuaCaputo New Member

    Joined:
    Aug 2, 2008
    Messages:
    605
    Likes Received:
    0
    Device:
    iPod touch
    yeah, figured it out by accident.

Share This Page