0

システム時刻を使用してデータを計算する mac osx 用の簡単なアプリケーションを作成します。クロックが 12:00 になるたびに特定のルーチンを実行したいのです
が、このためのシステム API はありますか?
どうすればいいですか?

実際には、アプリにステータスバー項目があり、グレゴリオ暦やイスラム暦など、選択したカレンダーで現在の日を表示します。この値をシステム時間と同期させたい

4

1 に答える 1

-1

ルーチンが次のメソッド- routine:(NSTimer *)timerの場合object:

NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate]; // Current time
NSTimeInterval then = ((int)now + 86400) % 86400; // Next 12am
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:then];
NSTimer *timer = [[NSTimer alloc] initWithFireDate:date interval:86400 target:object @selector(routine:) userInfo:nil repeats:YES];
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
于 2013-02-21T17:44:40.303 に答える