3

I'm writing a daily to do list app, and want the app to update certain elements with each new day. This isn't a problem if the user closes the app one day and then reopens it the next -- I just compare days in the startup methods.

However, this is a problem if the user happens to be using the app exactly at midnight. At midnight, daily task elements need to reset themselves automatically for the new day.

Here's my issue -- I could have a constant thread running in the background, always accessing [NSDate date] and checking for a new day. But I feel like there must be a better way, especially because this only has to happen once per day (and then, only if the user is using the app at midnight).

Thank you in advance!

4

1 に答える 1

2

applicationDidFinishLaunching:およびで、午前 0 時にトリガーapplicationWillEnterForeground:するスケジュールを設定します。NSTimerまた、UIApplicationSignificantTimeChangeNotificationタイムゾーンの変更などのためにタイマーを再スケジュールするために登録します。

于 2012-09-25T09:39:46.270 に答える