当前位置:首页 > 技术心得 > 正文内容

检测NSWindow关闭

xjtudll12年前 (2014-07-15)技术心得14810

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

 

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://xjtudll.cn/Exp/331/

标签: cocoa
分享给朋友:

“检测NSWindow关闭” 的相关文章

C# 去掉小数点后面多余的0

1、使用TrimEnd()    decimal num1=(decimal)0.5;    //第一步将浮点数转换成字符串    string strNum=num1.ToString(); &nb...

安卓弹出Dialog之后,点触摸屏幕任意区域,Dialog消失了的解决方法

参考资料: http://blog.csdn.net/liushuiwen101423/article/details/46412487 http://blog.csdn.net/u012255016/article/details/49888881 http://blog.csdn.net/jds...

未能加载文件或程序集“file:///C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports

首先我使用工具的信息为:Visual Studio 2010 ,水晶报表的版本为:13.0.0.99。 我想做的就是:使用VS2010中的WPF,将DataSet中的数据展示出来。(DataSet中的数据来自Oracle数据库) 但是我在运行的时候出现了这个问题: 未能加载文件或程序集“...

CRC除法

所有CRC原理介绍中,都会提到CRC除法。CRC除法与算术除法有什么区别呢?下面举个实例来说明。 以下是120 ÷ 9 来举例说明CRC除法: 120 = 1111000 B 9 = 1001 B  ...

Keil C51某些汉字不显示bug解决

Keil C51某些汉字不显示bug解决

这个问题是在用ST7920 LCD 12864时发现的,“星期三”中的“三”字显示不出来。经查,发现是Keil编译器的问题,编译器在编译汉字时会将汉字内码0xFD给过滤掉,导致汉字显示不正常。 一、直接用汉字编码 如果直接用编码则不会有这个问题。例如,...

OKI单片机——ML610Q4XX Melody Driver

OKI单片机——ML610Q4XX Melody Driver

配置流程: (1) Select a buzzer mode by setting the BZMD bit of the melody 0 control register (MD0CON) to “1”. (MD0CON寄存器的BZMD位置一)。 (2) Select...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。