Dưới đây là câu lệnh Chuyển/Trường hợp hiển thị thông báo lỗi khi không thể gửi email. Đối với hầu hết các phần, mọi thứ dường như đúng, nhưng khi tôi đặt một UIAlertView
vào câu lệnh switch tôi nhận được một lỗi trong Xcode:Sử dụng Tuyên bố Chuyển đổi trong Obj-C
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;
}
Tại sao nó tạo ra một lỗi khi tôi đặt mã bên trong case
?
xem [nhập liên kết mô tả ở đây] [1] [1]: http://stackoverflow.com/questions/366073/instantiating-new-object-within-switch-block-why- không-it-fail – TompaLompa
Không, UIAlertView không cần IBAction. – c0d3Junk13
bản sao có thể có của [Khi chuyển đổi dự án thành sử dụng ARC "trường hợp chuyển đổi nằm trong phạm vi được bảo vệ" nghĩa là gì?] (Http://stackoverflow.com/questions/7562199/when-converting-a-project-to-use- arc-what-does-switch-case-là-trong-bảo vệ-scop) – ughoavgfhw