How can I get notified of a system time change in my Cocoa application?

后端 未结 4 1961
一向
一向 2021-01-04 10:49

I have a Cocoa application that records datestamps on events. I need to know when the system time is reset and by how much, but I can\'t seem to fine a notification anywhere

4条回答
  •  一向
    一向 (楼主)
    2021-01-04 11:08

    I don't think there's a single way to do that because of the different mechanisms by which the time could change. But it wouldn't be very expensive (too expensive? Don't know, have you profiled it yet? ;-) to set an NSTimer once a second to check the time and compare it with the previous value. If it's not advanced by about a second, something interesting happened and you can notify your audit object.

提交回复
热议问题