How To Make IBAction Happen the 2nd Time Button Is Pressed

Discussion in 'iOS Programming' started by mandude, Dec 14, 2009.

  1. macrumors member

    Nov 19, 2009
    hi i have a simple UIButton named "button" with the IBAction "show" connected to it. I want it to be that when the user taps this button, nothing happens, but when the user taps it one more time, then the label magically appears. The user may tap the button once, and an hour later tap it again, and the label will only appear when the user taps the button "button" the second time. Here's the code:

    h. file:

    @interface PlayingCampeignViewController : UIViewController {

    UILabel *label;
    UIButton *button;
    NSUInteger *number;

    @property (nonatomic, retain) IBOutlet UILabel *label;
    @property (nonatomic, retain) IBOutlet UIButton *button;

    m. file:

    -(void)viewDidLoad {
    number = 0;

    -(IBAction)show {
    number = number + 1;
    if (number == 2) {
    label.hidden = NO;
  2. macrumors 68030


    Sep 2, 2008
    Are you uaecacher in disguise?

    Would you use the code tags?

    What's the question?

    Change this

    NSUInteger *number;
    to this

    NSUInteger number;
  3. thread starter macrumors member

    Nov 19, 2009
    hey thanks for the response... and ya i did that yet instead of my error before it now quits the first time i press the UIButton : P any more help and i would love you.
  4. thread starter macrumors member

    Nov 19, 2009

Share This Page