2012-04-08 17 views

答えて

12

私はViewControllerをで使用

//initWithNibName 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:self.view.window]; 

- (void)windowWillClose:(NSNotification *)notification 
    { 
     NSWindow *win = [notification object]; 
     //... 
    } 
+3

たり、 'NSWindowsDelegate'としてあなた' NSWindowController'を設定して行うことができます '[self.windowのsetDelegate:自己]'あなたのコントローラクラスに ' - (void)windowWillClose:(NSNotification *)notification'を追加してください。 –

1

NSWindowDelegateプロトコルに準拠するようにカスタムクラスを宣言できます。ウィンドウが閉じる前に何かをする:

は、これらの方法(1おそらくwindowWillClose)のいずれかを使用すると

あなたの窓のデリゲートなるようにカスタムクラスのインスタンスを設定します。

- (BOOL)windowShouldClose:(id)sender 
- (void)windowWillClose:(NSNotification *)notification 
関連する問題