다음은 전자 메일을 보낼 수 없을 때 오류 메시지를 표시하는 스위치/사례 문입니다. 대부분의 경우, 모든 것이 잘 보인다,하지만 난 스위치 문에 UIAlertView
를 배치 할 때 나는 엑스 코드에서 오류가 얻을 : 나는 내부 코드를 배치 할 때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;
}
왜 오류가 발생 않습니다를 case
?
보기 [1] [1] : http://stackoverflow.com/questions/366073/instantiating-new-object-within-switch-block-why- does-it-fail – TompaLompa
아니요, UIAlertView에는 IBAction이 필요하지 않습니다. – c0d3Junk13
복제 가능 [ARC를 사용하도록 프로젝트를 변환 할 때 "스위치 케이스가 보호 된 범위에 있음"이란 무엇입니까?] (http://stackoverflow.com/questions/7562199/when-converting-a-project-to-use- arc-what-does-switch-case-in-protected-scop) – ughoavgfhw