0

我不知道如何写这一行。我要做的是编写一个只执行一次的语句,完成后标记自己不再执行(以避免持续循环),例如白天和晚上。

我认为需要写的内容:

    if ([nightTime timeIntervalSinceNow] <= 0 && "check if already reset or not"){
        // The following process has to be done, but only once

        // reset dayTime (for tomorrow)

        // stop the current NSTimer

        // recreate a new NSTimer for nightTime        

   }

谁能指出我应该使用的正确方向?

非常感谢!

4

1 回答 1

0

Take one flag iIsProcessDone

if ([nightTime timeIntervalSinceNow] <= 0 && !iIsProcessDone){

        iIsProcessDone = YES;

        // The following process has to be done, but only once

        // reset dayTime (for tomorrow)

        // stop the current NSTimer

        // recreate a new NSTimer for nightTime        

   }

And reset it when you want to call this process again.

于 2012-05-24T05:58:16.273 回答