[NSDate 日付] から 00:00 (その日の始まり) の NSDate オブジェクトを取得する必要があります。現在、2012 年 1 月 6 日の午前 11 時 30 分 ([NSDate 日付] によって返される) であるとします。 2012 年 1 月 6 日の午前 0 時の NSDate が必要です。
私はこれを試していませんが、私の考えは次のとおりです。
NSDate *now = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:now];
[components setHour:0];
[components setMinute:0];
[components setSecond:0];
NSDate *morningStart = [calendar dateFromComponents:components];
したがって、最初に現在の日付 (2012 年 1 月 6 日とします) を取得し、日付の NSDateComponent を作成してから、時/分/秒を 0 に設定し、年/月/日は変更しないでください (つまり、01 /06/2012) 次に、このコンポーネント設定の NSDate を作成し、00:00:00 01/06/2012 の日付を取得できますか?