views:

118

answers:

1
+1  Q: 

NSTimer as Alarm

Is the best practice of setting an alarm on OS X to create a NSTimer scheduled for the number of seconds between the current time and the desired time for the alarm, or is there an alternative to that method?

+2  A: 

That is the best practice, yes. Timers don't poll and don't otherwise consume resources until fired.

Timers aren't particularly accurate in the fine grain, but should be "good enough" at anything in the 100s of milliseconds or greater range.

One thing to consider, though, is that the system may go to sleep and this can interfere with your timer. If you need to prevent sleep, consider carefully the impact on battery life and read up on Power Management.

bbum