How do you use the [NSDate dateWithTimeIntervalSinceNow:] method?
How do you use the [NSDate dateWithTimeIntervalSinceNow:]
method?
I would appreciate it if someone could post some example code. (There is no example in开发者_StackOverflow the documentation.)
NSDate * OneHourAway = [NSDate dateWithTimeIntervalSinceNow:3600]
The argument is in seconds. 3600 = 60 * 60 = 60 minutes = 1 hour
If you have an NSDate property called datePicker then see a possible use of dateWithTimeIntervalSinceNow
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.datePicker.minimumDate = [NSDate dateWithTimeIntervalSinceNow:60];
}
This will cause the datepicker to allow only dates that are 60 seconds from now
精彩评论