开发者

How do you use the [NSDate dateWithTimeIntervalSinceNow:] method?

开发者 https://www.devze.com 2022-12-13 08:05 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消