beginSheetModalForWindow:modalDelegate:didEndSelector:contextInfo:
シートでアラートパネルを表示します。
10.10で非推奨
-(void)beginSheetModalForWindow:(NSWindow *)window: modalDelegate:(id)delegate: didEndSelector:(SEL)didEndSelector: contextInfo:(void *)contextInfo:
解説
シートでアラートパネルを表示します。
パネルの終了時のために- (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo;
{}
というメソッドを使います。
returnCodeに押されたボタンの番号が戻されてきますのでそのコードをもとに分岐処理します。追加情報はcontextInfoを使って渡します。
【returnCode】
- 1 その他のボタン
0 キャンセルボタン
1 デフォルトボタン
返り値
( void )
なし
引数
( NSWindow * )window
( id )delegate
デリゲート
( SEL )didEndSelector
シート終了時に実行するメソッド
( void * )contextInfo
追加情報
フレームワーク
ApplicationKit
クラス
NSAlert
使用可能
10.3
編集時のバージョン
OS X 10.10
参照
-runModal
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSAlert *alert = [NSAlert alertWithMessageText:@"alertWithMessageText" defaultButton:@"defaultButton" alternateButton:@"alternateButton" otherButton:@"otherButton" informativeTextWithFormat:@"informativeTextWithFormat %@",@"text" ]; [alert beginSheetModalForWindow:[sender window] modalDelegate:self didEndSelector:@selector((alertDidEnd:returnCode:contextInfo:) contextInfo:nil ]; } - (void)alertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo; { NSLog(@"%d",returnCode); [self replyToShouldUnselect:YES]; } @end