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

后端 未结 4 1932
一向
一向 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:05

    Time moves constantly. A notification every time the current time changed would be a constant, CPU-soaking stream of notifications.

    What you need to do is get the current time in your event handler—the one that receives the events you're datestamping. You get the current time by calling [NSDate date].

提交回复
热议问题