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

Mac OS X:如何监测系统时间变更

xjtudll9年前 (2017-12-27)技术心得8390


目的:

 

当系统时间变更时,需要在app中知道。

其中系统时间变更包括时区,年月日时分秒等的变动,包括手动和自动修改

方法:

使用NSSystemClockDidChangeNotification

Mac 10.6开始支持

Apple added in NSSystemClockDidChangeNotification, part of NSDate, in Snow Leopard (10.6). There doesn't appear to be a way to do it in Leopard (10.5) or earlier. Per the Apple NSDate docs:

http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSDate_Class/Reference/Reference.html

参考资料里还讲了Mac 10.4的监测办法,对于我们没啥用。

 

参考资料:

https://stackoverflow.com/questions/690326/how-can-i-get-notified-of-a-system-time-change-in-my-cocoa-application

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

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

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

标签: cocoaMac
分享给朋友:

“Mac OS X:如何监测系统时间变更” 的相关文章

服务端把客户端几次发的数据一起接受了,是怎么回事?

服务端把客户端几次发的数据一起接受了,是怎么回事?

  客户端是android,服务端是c#,手机监听手指一动就把手指所在的那个点的位置发给服务端,服务端死循环接收,android可以保证一次是给服务端发一条数据,但是服务端把几次发的数据一起接受了 原因: 因为TCP是流式数据,没有次的概念。看题主的数据,结构本身比较简单,可以试试利用...

如何释放由RingtoneManage实例化的MediaPlayer

参考资料:http://stackoverflow.com/questions/15450255/how-to-release-the-mediaplayer-instantiated-by-ringtonemanager 为了获取android铃声的名称,使用了以下代码 //根据铃声地址获取铃声的...

Warning: xx pins must meet Altera requirements for 3.3-, 3.0-, and 2.5-V interfaces. For more information, refer to AN 447: Interfacing Cyclone IV E Devices with 3.3/3.0/2.5-V LVTTL/LVCMOS I/O Systems

Warning: xx pins must meet Altera requirements for 3.3-, 3.0-, and 2.5-V interfaces. For more information, refer to AN 447: Interfacing Cyclone IV E Devices with 3.3/3.0/2.5-V LVTTL/LVCMOS I/O Systems

问题描述: Cyclone IV EP4CE6E22C8N Quartus II编译 每次编译完,都有个warning: Warning: xx pins must meet Altera requirements for 3.3-, 3.0-, and 2.5-V interfaces. For...

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

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

AutoCAD 2010两则小设置

AutoCAD 2010两则小设置

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

Android Studio Build Output中文乱码

Android Studio Build Output中文乱码

1.双击shift  弹出如下窗口  选择Actions  找到Edit Custom VM Options 打开 2.打开后输入  -Dfile.encoding=UTF-8  保存重启  ok...

发表评论

访客

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