【发布时间】:2016-03-02 10:50:55
【问题描述】:
为什么 switch case 不占用多行 哪里可以完美工作
if(indexPath.row == 1){
UIViewController *viewController = [UIViewController new];
viewController.view.backgroundColor = [UIColor whiteColor];
viewController.title = _titlesArray[indexPath.row];
[self.navigationController pushViewController:viewControlleranimated:YES];
}
无法在 switch case 语句中使用相同的代码
switch (indexPath.row) {
case 0:
UIViewController *viewController = [UIViewController new];
viewController.view.backgroundColor = [UIColor whiteColor];
viewController.title = _titlesArray[indexPath.row];
[self.navigationController pushViewController:viewControlleranimated:YES];
break;
case 1:
break;
default
break:
}
在 switch 语句中它给出了一个错误.... 我强行使用 if else 语句 instated of switch case。 谁能建议我如何使用 switch case 语句。
【问题讨论】:
标签: objective-c if-statement switch-statement