开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜