Reputation: 41
I have an app that asks you a question (how many sides does this shape have) then I declare a uitextfield and call it txt, if u write 8 in the uitextfield and press done, you should go to the next question cause 8 was correct, here is my if statement code:
if (txt.text == @"8") {
[self q7done];
} else {
Fail *fail = [[Fail alloc]
initWithNibName:@"Fail" bundle:nil];
fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:fail animated:YES];
}
Okay! When I type in 8, it goes to the fail page. Sucks right, i dunno why??? I even tried setting the text of the uitextfield to a label of a 0.02 alpha and changed the if statement to if the LABELS text is 8 then blah blah blah, help pls.
Upvotes: 0
Views: 1091
Reputation: 284
NSString *string1 = yourtextfield.text;
NSString *string2= @"8";
if ([string1 isEqualToString:string2]) { //compare here.
[self q7done];
} else {
Fail *fail = [[Fail alloc]
initWithNibName:@"Fail" bundle:nil];
fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:fail animated:YES];
}
Upvotes: 0