Else if, or Xcode 中的语句。不知道我做错了什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8958891/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 23:04:00  来源:igfitidea点击:

Else if, or statement in Xcode. Not sure what I'm doing wrong

iphonexcodelogicif-statement

提问by davis

I'm not sure what I'm doing wrong, but Xcode keeps saying "Expected expression". What is wrong with the else if, or statement below?

我不确定我做错了什么,但 Xcode 一直说“预期的表达”。下面的 else if 或语句有什么问题?

else if ([currentClass rangeOfString:@"English"].location != NSNotFound) || ([currentClass rangeOfString:@"Literature"].location != NSNotFound) {
    cell.imageView.image = [UIImage imageNamed:@"englishicon.png"];

}

Thanks for your help

谢谢你的帮助

采纳答案by Rob Napier

You're missing an extra set of parentheses for the entire if().

您缺少整个if().

回答by Simon

You have to wrap your if statement between parentheses.

您必须将 if 语句括在括号之间。

if (([currentClass rangeOfString:@"English"].location != NSNotFound) || ([currentClass rangeOfString:@"Literature"].location != NSNotFound)) {