Objective c 开关函数中的预期表达式错误-目标-C
我正在学习开关函数,所以我更改了if和else语句,如下所示: 但它给了我“预期表达式”的错误 为什么? //这个是正确的Objective c 开关函数中的预期表达式错误-目标-C,objective-c,if-statement,switch-statement,Objective C,If Statement,Switch Statement,我正在学习开关函数,所以我更改了if和else语句,如下所示: 但它给了我“预期表达式”的错误 为什么? //这个是正确的 if (indexPath.section == 0) { cell.textLabel.text = FileANames[indexPath.row]; cell.detailTextLabel.text = FileADetails[FileANames[indexPath.row]]; } else if (indexPath.section ==
if (indexPath.section == 0) {
cell.textLabel.text = FileANames[indexPath.row];
cell.detailTextLabel.text = FileADetails[FileANames[indexPath.row]];
}
else if (indexPath.section == 1) {
cell.textLabel.text = FileBNames[indexPath.row];
cell.detailTextLabel.text = FileBDetails[FileBNames[indexPath.row]];
}
else if (indexPath.section == 2) {
cell.textLabel.text = FileCNames[indexPath.row];
cell.detailTextLabel.text = FileCDetails[FileCNames[indexPath.row]];
}
return cell;
}
谢谢。应该是这个
switch (indexPath.section) {
case 0: {
cell.textLabel.text = FileANames[indexPath.row];
cell.detailTextLabel.text = FileADetails[FileANames[indexPath.row]];
break;
}
case 1: {
cell.textLabel.text = FileBNames[indexPath.row];
cell.detailTextLabel.text = FileBDetails[FileBNames[indexPath.row]];
break;
}
case 2: {
cell.textLabel.text = FileCNames[indexPath.row];
cell.detailTextLabel.text = FileCDetails[FileCNames[indexPath.row]];
break;
}
default: break;
}
return cell;
不要像这样执行
返回操作。同时执行中断操作
。谢谢!现在可以了。@Xcode初学者-没关系,请将其标记为已回答
switch (indexPath.section) {
case 0: {
cell.textLabel.text = FileANames[indexPath.row];
cell.detailTextLabel.text = FileADetails[FileANames[indexPath.row]];
break;
}
case 1: {
cell.textLabel.text = FileBNames[indexPath.row];
cell.detailTextLabel.text = FileBDetails[FileBNames[indexPath.row]];
break;
}
case 2: {
cell.textLabel.text = FileCNames[indexPath.row];
cell.detailTextLabel.text = FileCDetails[FileCNames[indexPath.row]];
break;
}
default: break;
}
return cell;