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

检测NSWindow关闭

xjtudll13年前 (2014-07-15)技术心得15400

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

Storyboard已关联下面的TableView,为什么TabView的Cell显示不出来

问题: Storyboard已关联下面的TableView,为什么TabView的Cell显示不出来 原因及解决办法: 很简单,你的代码没有设置,SB里面的TableViewController要关联一个类,你需要添加好,并且注意下面这两个代理方法的返回值 - (NSInteger)numberO...

UltraEdit复制粘贴十六进制(二进制)

UltraEdit复制粘贴十六进制(二进制)

问题: 用UltraEdit打开文件,看其十六进制,需要将十六进制数据复制出来并粘贴到记事本。但是直接复制(或Ctrl+C),无法粘贴到记事本。 原因: 复制到剪贴板的是二进制码流,而不是文本,所以无法贴到只能处理文本的记事本里。 解决办法: 选中要复制的区域,右键--->【十六进制复制所选视...

eclipse:android R.java文件丢失或无法更新

eclipse:android R.java文件丢失或无法更新

http://www.cnblogs.com/zdz8207/archive/2012/11/30/eclipse-android-adt-update.html 问题: eclipse编译android工程,发现R.java无法更新 解决办法: 1、先确定SDK没问题,就是说工程设置里用的SDK,...

密勒定理及密勒效应

密勒定理及密勒效应

1、密勒定理 如图1所示的二端口网络(two-port network)中,Vin为输入电压,Vout为输出电压,Zf为Vin与Vout之间的桥接阻抗,A为Vin与Vout之间的闭环增益(A>0,正相放大;A<0,反相放大),且A的输入阻抗为无穷大,输出阻抗为零,则图1电路与图2电...

Xcode查找函数(方法)调用及被调用

Xcode查找函数(方法)调用及被调用

参考资料:http://stackoverflow.com/questions/7145045/find-method-references-in-xcode 这个功能有的说是 Find Caller,有的说是Find references,有的说是Find Usages 直白的讲,就是我需要知道这...

C#实现重启应用程序

推荐使用: Application.Restart();...

发表评论

访客

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