문제

I grab the current time

NSDate * now = [[NSDate alloc] init];
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents * comps = [cal components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit fromDate:now];

And I can set the DatePicker to any values I desire

NSDate * date = [cal dateFromComponents:comps];
[self.off setDate:date animated:TRUE];

But how do I add a, say, 5 minutes to "now"?

도움이 되었습니까?

해결책

Try this

NSDate *date = [[NSDate date] dateByAddingTimeInterval:5*60];

다른 팁

Try

NSDate *now = [NSDate dateWithTimeInterval:300 sinceDate:[NSDate date]]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top