我尝试使用开关
执行不同的功能 switch (self.requestID) {
case 0:
[self setTableData:[jsonDic objectForKey:@"listinofs"]];
if ([self.tableData count] != 0) {
[self.dbTableView reloadData];
}
break;
case 10:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"great!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
break;
default:
break;
}
但case 10:
下的行会报告错误expected expression
,我不明白,你能帮助我吗?
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"great!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
这些代码报告错误。
答案 0 :(得分:-3)
将NSLog放在UIALertview上,你会看到错误将消失......是的,我们不能在切换案例中直接初始化UIAlertview ....它应该在{}。
switch (val) {
case 10:
{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"great!!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alertView show];
}
break;
}