我有一个if语句:

if ([txt.text isEqualToString:@"8"]) {
    [self q7done];
} else {
    Fail *fail = [[Fail alloc]
                  initWithNibName:@"Fail" bundle:nil];
    fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:fail animated:YES];

}

如果txt.text isEqualToString,8 OR或8,我该如何确定。我试过了:
if ([txt.text isEqualToString:@"8", @"Eight"]) {
    [self q7done];
} else {
    Fail *fail = [[Fail alloc]
                  initWithNibName:@"Fail" bundle:nil];
    fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:fail animated:YES];

}

提示我说了太多论点时出错

最佳答案

if ([txt.text isEqualToString:@"8"] || [txt.text isEqualToString:@"Eight"])

请通过Google“C逻辑和或运算符”获得大量教程。

关于objective-c - 除了or或and,在if语句中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6660262/

10-11 19:48