【发布时间】:2012-04-14 06:47:09
【问题描述】:
下面是一个 Switch / Case 语句,当无法发送电子邮件时显示错误消息。在大多数情况下,一切似乎都是正确的,但是当我将 UIAlertView 放入 Switch 语句时,我在 Xcode 中收到错误:
switch (result) {
case MFMailComposeResultCancelled:
NSLog(@"Result: Mail sending canceled");
break;
case MFMailComposeResultFailed:
NSLog(@"Result: Mail sending failed");
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Sending Failed"
message:@"The email could not be sent."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[message show];
break;
default:
NSLog(@"Result: Mail not sent");
break;
}
为什么我在case里面放代码会报错?
【问题讨论】:
-
看看[在此处输入链接描述][1] [1]:stackoverflow.com/questions/366073/…
-
不,UIAlertView 不需要 IBAction。
标签: ios objective-c compiler-errors switch-statement