beginSheet:modalForWindow:modalDelegate:didEndSelector:contextInfo:
10.10で非推奨
代わりにNSWindowのbeginSheet:completionHandler: を使用します。
シートウインドウでモーダルセッションを開始します
Objective-C
-(void)beginSheet:(NSWindow *)sheet: modalForWindow:(NSWindow *)docWindow: modalDelegate:(id)modalDelegate: didEndSelector:(SEL)didEndSelector: contextInfo:(void *)contextInfo:
Swift
ありません
解説
シートウインドウでモーダルセッションを開始します。
ウインドウが閉じた時の処理のために下記のメソッドが必要です。
- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
返り値
( void )
なし
引数
( NSWindow * )sheet
シート
( NSWindow * )docWindow
ドキュメントウインドウ
( id )modalDelegate
デリゲート(didEndSelectorが含まれるオブジェクト)
( SEL )didEndSelector
終了時に実行するセレクタ
( void * )contextInfo
追加情報
フレームワーク
ApplicationKit
クラス
NSApplication
Instance Methods
使用可能
10.0
参照
例文
#import "Controller.h" @implementation Controller - (IBAction)pushButton:(id)sender { [NSApp stopModal]; //userInfoに使う辞書を作成 NSDictionary *userInfoDictionary =[NSDictionary dictionaryWithObjectsAndKeys: @"value1",@"key1", @"value2",@"key2", @"value3",@"key3",nil]; [NSApp beginSheet:panelWin modalForWindow:myWindow modalDelegate:self didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: &userInfoDictionary ]; } - (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { if (returnCode == NSAlertDefaultReturn){ NSLog(@"YES"); }else{ NSLog(@"Cansel"); } [sheet orderOut:self]; NSLog(@"returnCode %d",returnCode); NSLog(@"returnCode %p",contextInfo); } @end