So to put up a code with an example of what I'm trying to achieve today is my new game.. whozapp with initially is going to make a game based on images that you have to guess.
Here is the code for the "viewcontroller.h"
#import
@interface ViewController : UIViewController{
NSString *Answerstring;
}
//declaring the properties.
@property (weak, nonatomic) IBOutlet UITextField *AnswerText;
@property (weak, nonatomic) IBOutlet UIButton *AnswerButton;
@property (weak, nonatomic) IBOutlet UILabel *Answerlabel;
// need to declare the IBaction for the control we are passing the event.
- (IBAction)AnswerButtonClicked:(id)sender;
//declaring properties for the sports Category
@end
and the code for the viewcontroller.m :
(IBAction)AnswerButtonClicked:(id)sender {
[AnswerText resignFirstResponder];
Answerstring = AnswerText.text;
//userTwoString = user2.text;
if([Answerstring isEqual:@"George Bush"] || [Answerstring isEqual:@"George W. Bush"] ||
[Answerstring isEqual:@"Bush"] || [Answerstring isEqual:@"George"] ){
Answerlabel.text = @"You are correct, continue!";
Answerlabel.textColor = [UIColor whiteColor ];
//Answerlabel.backgroundColor = [UIColor blueColor];
}else{
Answerlabel.text = @"Sorry Incorrect, hint:former President of USA ";
Answerlabel.textColor = [UIColor whiteColor ];
Answerlabel.backgroundColor = [UIColor magentaColor];
}
is we see here is just validating the data with a plain, vulgar text on the condition but we are going to put this on a enum so we can have a cleaner elegant code.