检测NSWindow关闭

0

本文作者:xjtudll  发布于:2014-7-15  分类:技术心得  点击:


You can declare your custom class to conform to NSWindowDelegate protocol.

Set an instance of your custom class to be the delegate of your window

Then use one of these methods (probably the windowWillClose: one) to do something before the window closes.

 
- (BOOL)windowShouldClose:(id)sender
 
- (void)windowWillClose:(NSNotification *)notification
 

- (void)windowWillClose:(NSNotification *)notification{ 
 
      settingWindowsOpen = FALSE; 
 
     [self writeUserNTPServer]; //写入NTP 服务器数据

 

}

 


也可以与NSWindowsDelegate关联(可以用代码实现,也可以用IB),也可以自己添加observer

自己添加observer:
 
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:self.view.window];

 

本文标签: cocoa  
本文Url: http://www.xjtudll.cn/Exp/331/ (出自: 鸟的天空)
我要引用: 点击这里获取该日志的TrackBack引用地址

相关文章:

330. NSToolBar-设定初始化选中的item  (2014-7-11 9:6:2)

329. NSWindow——设定窗口位置  (2014-7-8 11:5:14)

328. NSButton——设定背景图片Scale  (2014-7-5 7:2:31)

327. NSTableview从mutable array获取数据  (2014-7-3 16:50:26)

317. Cocoa Mac应用程序创建DMG打包发布  (2014-5-6 11:10:19)

312. NSTextfield只允许输入数字  (2014-4-26 19:31:12)

0 Comments

Write a comment ?