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

检测NSWindow关闭

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

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

Windows 2008 Server R2增量备份

Windows 2008 Server R2增量备份

Windows 2008 server R2在默认情况下都是完整备份,如果这么搞的话,空间很快就不够用了。 其实windows 2008 r2是有增量备份功能的,只不过这个功能隐藏的太深了。 Windows Server Backup -> 配置性能设置 -> 优化备份性能 ->...

NSButton——设定背景图片Scale

NSButton——设定背景图片Scale

参考资料: http://stackoverflow.com/questions/5851923/how-to-scale-axes-independently-at-runtime-on-an-nsbutton 代码方式: NSButton *someButton; NSButtonCell...

QuartusII编译工程后显示资源消耗为零的原因

参考资料:http://www.eefocus.com/li_mengxiang/blog/11-04/208828_3da3b.html 近日,编译了一个CPLD工程,编译OK,无任何错误,但是显示资源消耗为0,这个显然是不正常的。 网上搜了一番,一般是两种原因: 1、qurtusII编译工程后显...

iPad2插电循环重启,无法充电

老爷机iPad2最近发疯了: 1、不插充电器 无法开机; 2、插上普通充电器,木有反应; 3、插上专用的5V,2.1A充电器,有时可开机,但一会儿就关机了。然后又自动开机。循环往复。 经过分析,初步确定是电池有问题(机子本身无进水无维修) 可以参考下面的讨论: https://discussions...

Android Studio Warning:Not annotated parameter overrides @NonNull parameter

问题: android studio提示:Not annotated parameter overrides @NonNull parameter 分析: Warning:The @NonNull annotation can be used to indicate that a given par...

Quartus CPLD未使用引脚处理

Quartus CPLD未使用引脚处理

未使用的引脚可以设置成输出,三态输入,弱上拉输入等。Quartus 8.0默认设置成输出低电平(As output driving ground)。 引脚设置方法: 【Assignments】->【Setting】->【Device】->【Device and Pin Option...

发表评论

访客

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