以下は、電子メールを送信できないときにエラーメッセージを表示するSwitch/Caseステートメントです。ほとんどの部分については、すべてが右のようだが、私はswitch文の中にUIAlertView
を置くとき、私はXcodeでエラーが発生します。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-アークは何ですか?スイッチケースの保護スコープにあります) – ughoavgfhw