NSApplication Delegate and Preference Pane
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
.
source to share
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;
source to share