我正在尝试使用 NSDateComponent 设置今天日期的一些组件,如下所示:
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:1];
[comps setHour:1];
[comps setMinute:44];
NSCalendar *cal = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDate *date = [cal dateByAddingComponents:comps toDate:[NSDate date] options:0];
[comps release];
NSLog(@"%@", date);
但是这个例子会将时间添加到当前日期。现在我想做的是添加一天,但将小时和分钟设置为指定的值(不添加)。我怎样才能做到这一点?