I don't know how to make an if-else statement within an IBAction! I can only make them in the button clicks... what I want it to do is check for which # the int question is at and make the appropriate changes. please help!
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MainView : UIView{
IBOutlet UIImageView *background;
IBOutlet UIButton *button1;
IBOutlet UIButton *button2;
IBOutlet UIButton *button3;
IBOutlet UIButton *button4;
IBOutlet UILabel *questionLabel;
}
@property (nonatomic, retain) UIButton *button1;
@property (nonatomic, retain) UIButton *button2;
@property (nonatomic, retain) UIButton *button3;
@property (nonatomic, retain) UIButton *button4;
@property (nonatomic, retain) UILabel *questionLabel;
@property (nonatomic, retain) UIImageView *background;
- (IBAction)Button1clicked;
- (IBAction)Button2clicked;
- (IBAction)Button3clicked;
- (IBAction)Button4clicked;
@end
MainView.m
#import "MainView.h"
@implementation MainView
@synthesize button1, button2, button3, button4, questionLabel, background;
int question = 1;
BOOL oneRight = FALSE;
BOOL twoRight = FALSE;
BOOL threeRight = FALSE;
BOOL fourRight = FALSE;
- (IBAction)Button1clicked {
if (oneRight == TRUE) {
questionLabel.text = @"CORRECT!";
question++;
} else {
questionLabel.text = @"FAIL";
}
}
- (IBAction)Button2clicked {
if (twoRight == TRUE) {
questionLabel.text = @"CORRECT!";
question++;
} else {
questionLabel.text = @"FAIL";
}
}
- (IBAction)Button3clicked {
if (threeRight == TRUE) {
questionLabel.text = @"CORRECT!";
question++;
} else {
questionLabel.text = @"FAIL";
}
}
- (IBAction)Button4clicked {
if (fourRight == TRUE) {
questionLabel.text = @"CORRECT!";
question++;
} else {
questionLabel.text = @"FAIL";
}
}
int foo(int question) {
if (question == 1) {
oneRight = TRUE;
twoRight = FALSE;
threeRight = FALSE;
fourRight = FALSE;
}
}
@end