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

检测NSWindow关闭

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

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://www.xjtudll.cn/Exp/331/

标签: cocoa
分享给朋友:

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

Android MultiSelectListPreference, java.lang.String cannot be cast to java.util.Set

问题及现象: 尝试添加一个 MultiSelectListPreference到设置界面,MultiSelectListPreference基本代码如下: <MultiSelectListPreference android:title="@string/title" an...

php gettext无效解决

php gettext无效解决

 代码:$lang = 'en_US'; //linux不支持zh-Hans,所以gettext、php都不支持。使用locale -a可以看到os支持的语言文字国家地区码。putenv('LANGUAGE='&nbs...

如何在fragment里启动service

参考资料:http://stackoverflow.com/questions/13007355/how-to-start-service-from-fragments 问题: 如果在fragment里直接用startService,那么编译将不会通过。 如下代码在activity里是可以正确使用的...

Xcode Error:ARC forbids explicit message send of release解决及自定义ARC

Xcode Error:ARC forbids explicit message send of release解决及自定义ARC

首先:Xcode 5中是可以选择是否用ARC的,在有ARC的时候,你完全不需要也不允许做retain,release,你要考虑strong 还是weak。推荐使用ARC。 如果不用ARC,是可以去掉的。在target->build settings里面,有个APPLE LLVM 5.0 La...

两个IO 6按键

两个IO 6按键

分析: 首先:IO1,IO2输出高电平 S1按下,IO2为低电平 S2按下,IO1为低电平 S3按下,IO1,IO2为0.7V(1N4148导通电压),还是低电平。 现在开始判别其他几个按键了: 1、IO1输出低电平,读IO2电平 ① 如果IO2为低电平,此时应该是S4或者S6按下(S6按下时,...

如何获取.NET Framework目录路径?

问题: 如何在C#应用程序中获取.NET Framework目录路径? 例如:“C:\ WINDOWS \ Microsoft.NET \ Framework \ v2.0.50727” 方法: 通过使用以下方法可以获取当前.NET应用程序活动的CLR安装目录的路径: Sys...

发表评论

访客

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