在switch的case语句后,使用UIAlertView报错

错误提示如下:

分析:

      You are using multiline case statement. Your statements must be enclosed in { and }.

  The problem is declaring variables inside cases of a switch. The compiler is upset about trying to figure out scope when only some of the code is executed. If you put brackets around the contents of the 'fail' case, it should be OK since that restricts the scope.

修改方案:

1)不要在case 下声明变量

2)多个case下,可用{}将case中的代码括起来。

效果如下:

                case 2:{
                    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"
                                                                    message:@"验证码信息不正确,请重新获取验证码!"
                                                                   delegate:self
                                                          cancelButtonTitle:@"关闭"
                                                          otherButtonTitles:nil];
                    [alert show];
                    [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(dismissAlert:) userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert,@"alert", nil] repeats:NO];
                    [alert release];
                    break;
                } 
          case 3: ⋯⋯

转载于:https://www.cnblogs.com/ygm900/archive/2012/12/12/2814523.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值