[Objective-C] objective C 过期后杀掉应用程序 →→→→→进入此内容的聊天室

来自 , 2019-03-25, 写在 Objective-C, 查看 143 次.
URL http://www.code666.cn/view/488b0841
  1. // Based on original code by Daniel Jakult, based on an idea from Brian Cooke.
  2. #ifdef BETA  // 4 week expiration
  3. #define EXPIREAFTERDAYS 28
  4. #endif
  5.  
  6. #if EXPIREAFTERDAYS
  7. NSString* compileDateString = [NSString stringWithUTF8String:__DATE__];
  8. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  9. [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
  10. [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@”en_US”]
  11.         autorelease]];
  12. [dateFormatter setDateFormat:@"MMM dd yyyy"];
  13. NSDate *compileDate = [dateFormatter dateFromString:compileDateString];
  14. [dateFormatter release];
  15. NSDate *expireDate = [compileDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)];
  16.  
  17. if ([expireDate earlierDate:[NSDate date]] == expireDate)
  18. {
  19.         // Run an alert or whatever
  20.  
  21.         // Quit!
  22.         [NSApp terminate:self];
  23. }
  24. #endif
  25. //objectc/4030

回复 "objective C 过期后杀掉应用程序"

这儿你可以回复上面这条便签

captcha