2008-11-28 90 views

回答

4

Cocoa框架中的大多数委托方法只是通知方法。这包括application{Will,Did}{Become,Resign}Active:,这是NSApplication{Will,Did}{Become,Resign}ActiveNotification的通知方法。通知与代表方法位于同一位置:the NSApplication documentation

因此,只需注册本地NSNotificationCenter上的通知即可。

+0

谢谢,作品像魅力。我将此通知与FSEvents结合使用来刷新NSTableView。根据我的调试,一切正常,直到我在视图上调用setDataSource。该视图只是不更新​​。任何想法发生了什么? – 2008-11-29 01:03:19

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;