別のNSAlertからの応答に基づいてNSAlertを起動する必要があります。ただし、最初のdidEndSelectorから呼び出そうとすると、あらゆる種類の厄介なことが起こります(ドキュメントウィンドウが消えたり、コンソールへの印刷の順序に関する警告が表示されたりします)。
何かご意見は?
別のNSAlertからの応答に基づいてNSAlertを起動する必要があります。ただし、最初のdidEndSelectorから呼び出そうとすると、あらゆる種類の厄介なことが起こります(ドキュメントウィンドウが消えたり、コンソールへの印刷の順序に関する警告が表示されたりします)。
何かご意見は?
あなたがやろうとしているのは、アラートを「連鎖」させることです。
これを行うorderOut:
には、アラートウィンドウを呼び出す必要があります。
ドキュメントは次のとおりです。
モーダルデリゲートが戻り値に応答してアクションを実行する前にalertDidEndSelectorメソッド内からシートを閉じる場合は、ウィンドウをアラート引数に送信して取得したウィンドウオブジェクトにorderOut:(NSWindow)を送信します。これにより、たとえば、alertDidEndSelectorメソッド内から次のシートを表示する前に1つのシートを閉じることにより、シートをチェーンすることができます。alertDidEndSelectorメソッドが呼び出される前に、プログラムの他の場所からシート上でorderOut:を呼び出さないように注意する必要があることに注意してください。
もっと簡単な方法があります。if[runModal]
ステートメントの内容を確認するだけです。
//setup the dialog
NSAlert *networkErrorDialog = [NSAlert alertWithMessageText:@"Couldn't connect to the server" defaultButton:@"Network Diagnostics" alternateButton:@"Quit" otherButton:nil informativeTextWithFormat:@"Check that your computer is connected to the internet and make sure you aren't using a proxy server or parental controls"];
//show the dialog inside an IF, 0=the first button 1=the 2nd button etc
if ([networkErrorDialog runModal]==0) {
//quit
[[NSApplication sharedApplication] terminate:self];
} else {
//Network Diagnostics
[[NSWorkspace sharedWorkspace] launchApplication:@"Network Diagnostics"];
[[NSApplication sharedApplication] terminate:self];
}
それが役立つことを願っています