osx - Run code at a certain time according to the system clock -


What is the best way to run the code while changing the system clock at any given time? Obviously I could choose, but it seems inefficient.

I do not want a timer; I want to be able to do something in the evening (for example) at 10:00.

NSTimer is a lot that you do something later in Coca, And it is possible to make one with a "date of fire", but the date will be closed if the computer sleeps in the middle (or if the clock changes).

Voting through a timer can not be such a bad option; This allows you many scheduled programs but only one mechanism is activating them. A timer that repeats every 15 or 30 seconds and looks through a list of NSDates that it should be seen that something should be, there should not be a meaningful display effect.

Another option is using a noodlekit NSTimer is a blog post about the category that accounts for clock changes: and the code is available on GitHub: The timer itself NSWorkspace along with sleep / net notifications registers for time zone change notifications and adjusts its fire time accordingly.

Comments