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

检测NSWindow关闭

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

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关闭” 的相关文章

Protel99SE添加泪滴焊盘

Protel99SE添加泪滴焊盘

在电路板设计中,为了让焊盘更加坚固,防止机械制板时焊盘与导线之间断开,常在焊盘和导线之间用铜膜布置一个过渡区,形状像泪滴,故常称做补泪滴(Teardrops)。 泪滴的放置可以执行主菜单命令 Tools->Teardrops,将弹出如图所示的 Teardrop ptions (泪滴)设置对话...

Android Studio: This version of the rendering library is more recent than your version of Android Studio

Android Studio: This version of the rendering library is more recent than your version of Android Studio

Android Studio预览xml布局时,提示: This version of the rendering library is more recent than your version of Android Studio. Please update Android Studio 如图所示...

LCD基本常识

1、LCD的玻璃厚度有1.1mm、0.7mm、0.55mm和0.4mm,成品总厚度分别为2.8mm、2.0mm、1.7mm和1.4mm,如果是FSTN产品,那么总厚度需要再增加0.1mm。 2、LCD的视角范围,STN产品视角范围最大,HTN产品次之,TN产品视角范围最小。对于多路产品,如果路数大于...

Android手机Google服务耗电过多

手机:三星I9000 操作系统:Android 2.3.3 (Lida ROM) 现象:电池使用时间很短,经常莫名其妙就没电了。查看电量消耗,60%(甚至更多)为“Google框架服务”占用。 病因: 通过网络搜索,发现是因为曾经禁止了“Google框架服务&rd...

AutoCAD 2010两则小设置

AutoCAD 2010两则小设置

以前一直用AutoCAD2004,最近升级为AutoCAD2010,发现使用有些不同,尤其是一些设置,很难找到入口,所以也就不知从何设置。 一、AutoCAD2010更改图纸背景为黑色 AutoCAD2010默认图纸背景是白色,而之前大量的图纸都是在黑色背景下完成的。如果背景不更改为黑色,看起来很不...

Altium检查遗漏的封装

Altium检查遗漏的封装

画完原理图后,当然就要检查封装是否填写以及填写是否正确。虽然用Compile能够找到封装的问题,但是Compile之后的message不仅仅包含封装的错误,还包括其他,看起来不甚直观,操作也不是很方便。以前在用Protel99SE的时候,可以通过导出电子表格的方式来检查封装是否正确。高版本的Alti...

发表评论

访客

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