使用 NSTimeInterval 的应用程序过期
我如何设置此方法以在应用程序首次启动后 30 天显示警报面板?
-(void)awakeFromNib
{
NSDate * today = [NSDate date];
NSTimeInterval expiry = ();
if ([today timeIntervalSinceReferenceDate] > expiry){
NSRunAlertPanel(@"Trial period has ended", @"Please Register", nil, nil, nil);
NSLog(@"expired");
[[NSApplication sharedApplication] terminate:self];
}
}
How would I set this method to display the alert panel 30 days from the initial launch of the application?
-(void)awakeFromNib
{
NSDate * today = [NSDate date];
NSTimeInterval expiry = ();
if ([today timeIntervalSinceReferenceDate] > expiry){
NSRunAlertPanel(@"Trial period has ended", @"Please Register", nil, nil, nil);
NSLog(@"expired");
[[NSApplication sharedApplication] terminate:self];
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 上的
day
属性NSDateComponents
用于计算距离当前日期一定数量的日期:此检查仅应在应用程序第一次打开时进行。
expDate
应保留。每次应用程序在第一次后重新启动时,请与第一次日期进行日期比较。Use the
day
property onNSDateComponents
to calculate a date a certain number of dates from the current date:This check should only be done the first time the app opens.
expDate
should be persisted. Every time the app launches fresh after the first time, do a date comparison from that first date.