次の 1 時間までのカウントダウンを行いたいと思います。次のように、特定の時間までカウントダウンするのは非常に簡単です。
NSDate *midnight = [NSDate dateWithNaturalLanguageString:@"midnight tomorrow"];
「毎時開始」の NSDate を定義するにはどうすればよいですか?
ありがとう!
編集:これは私が現在持っているものです。ソリューションをコードに統合するのに問題があります。どんな助けでも大歓迎です。:)
-(void)updateLabel {
NSDate *now = [NSDate date];
NSDate *midnight = [NSDate dateWithNaturalLanguageString:@"midnight tomorrow"];
//num of seconds between mid and now
NSTimeInterval timeInt = [midnight timeIntervalSinceDate:now];
int hour = (int) timeInt/3600;
int min = ((int) timeInt % 3600) / 60;
int sec = (int) timeInt % 60;
countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, min,sec];
}