NSApplication Delegate and Preference Pane

I can't seem to manage the NSApp delegate from the system preference pane, which is understandable. Is there any other way that my object can be notified when the program becomes active?

0


source to share


2 answers


Most of the delegate methods within Cocoa are just notification methods. This includes application{Will,Did}{Become,Resign}Active:

which are the notification methods for NSApplication{Will,Did}{Become,Resign}ActiveNotification

. Notifications are in the same place as delegate methods: NSApplication documentation .



So, just register for these notifications locally NSNotificationCenter

.

+4


source


NSPreferencePane gives you several methods that you can override to respond to changes. Specifically, mainViewDidLoad:

it gives you the ability to initialize when the preference bar becomes active for the first time.

If you really wanted to keep track of when the System Preferences window becomes primary or key, you can subscribe to NSWindow notifications for these events.



//  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;

      

+3


source







All Articles