开发者

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 d开发者_Go百科esired time for the alarm, or is there an alternative to that method?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜