0

システム環境設定ペイン内から NSApp デリゲートを制御できないようですが、これは理解できます。プログラムがアクティブになったときにオブジェクトに通知する他の方法はありますか?

4

2 に答える 2

4

Cocoa フレームワークのデリゲート メソッドのほとんどは、単なる通知メソッドです。これにはapplication{Will,Did}{Become,Resign}Active:、 の通知方法である が含まれNSApplication{Will,Did}{Become,Resign}ActiveNotificationます。通知はデリゲート メソッドと同じ場所にあります: NSApplication ドキュメント

したがって、ローカル でこれらの通知にサインアップするだけNSNotificationCenterです。

于 2008-11-28T23:16:19.860 に答える
3

NSPreferencePane は、変更に対応するためにオーバーライドできるいくつかのメソッドを提供します。特に、mainViewDidLoad:環境設定ペインが初めてアクティブになったときに初期化を行う機会が与えられます。

システム環境設定ウィンドウがいつメインまたはキーになるかを追跡したい場合は、それらのイベントに関する NSWindow の通知にサブスクライブできます。

//  These messages get sent to the a preference panel just before and
//  just after it becomes the currently selected preference panel.
- (void) willSelect;
- (void) didSelect;

//  The willUnselect message gets sent to the currently selected preference panel
//  just before and just after it gets swapped out for another preference panel
- (void) willUnselect;
- (void) didUnselect;
于 2008-11-28T22:11:13.800 に答える