objective-c - if else 语句的预期表达式错误

标签 objective-c ios xcode if-statement

<分区>

对于我代码中的第二个 else if 语句,Xcode 提示“需要预期的表达式”。我试过使用我在这里看过的代码中的括号,但是那没有用,而且不确定它现在想要什么表达式?工作正常,直到我添加第二个 else if 我意识到这可能是基本的 Objective-C 东西,但是从来没有为超过两个项目做过 if 语句,我有点卡住了

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{


if ([text1 isFirstResponder])return arrStatus.count;

else


   if ([text2 isFirstResponder]);return arrStatus2.count;

   else ///<<<<< wants an expected expression here


       if ([text3 isFirstResponder]);return arrStatus2.count;

 }

最佳答案

您只是在第二个 if 语句中多了一个分号。 它应该是:if ([text2 isFirstResponder]) return arrStatus2.count;

附言。您在第 3 个 if 上也犯了同样的错误......您真的应该考虑使用大括号,即使是单行代码。

关于objective-c - if else 语句的预期表达式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11739663/

上一篇:android - 非游戏程序员的手机游戏框架

下一篇:ios - titanium mobile navgroup.open 新窗口完全呈现之前的过渡

相关文章:

ios - 在 iOS 中将通知从模型发送到 Controller

ios - 如何使用CoreLocation获取多个iBeacon?

ios - 使用 geofire 进行一次性位置更新? swift 4

iOS: Assets 目录中启动图像上的黑线

iphone - Core Data 可以使用 Web 服务作为持久性存储吗?

ios - 解析.com : Pass an array of dictionaries to backgroundJob through httprequest

ios - iOS 13 和 Xcode 11 的布局问题

ios - js构建错误: Error: Your ios platform does not have Api.

iphone - Objective-C 静态分析工具——Xcode 的插件?

ios - 如何捕获 AVCaptureSession 的一部分?