kill app after expire date


/ Published in: Objective C
Save to your folder(s)

Using a gcc predefined macro, __DATE__, the code can know for itself when it was compiled, and build in an expiration date based on that value.

For a internationalised version see: http://snipplr.com/view/7196/kill-app-after-expire-date-suicidal-code-redux/


Copy this code and paste it in your HTML
  1. // For a internationalised version
  2. // see: http://snipplr.com/view/7196/kill-app-after-expire-date-suicidal-code-redux/
  3.  
  4. // Two-week expiration
  5. #define EXPIREAFTERDAYS 14
  6.  
  7. #if EXPIREAFTERDAYS
  8. // Idea from Brian Cooke.
  9. NSString* nowString =
  10. [NSString stringWithUTF8String:__DATE__];
  11. NSCalendarDate* nowDate =
  12. [NSCalendarDate dateWithNaturalLanguageString:nowString];
  13. NSCalendarDate* expireDate =
  14. [nowDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)];
  15.  
  16. if ([expireDate earlierDate:[NSDate date]] == expireDate)
  17. {
  18. // Run an alert or whatever
  19.  
  20. // Quit!
  21. [NSApp terminate:self];
  22. }
  23. #endif

URL: http://www.red-sweater.com/blog/371/suicidal-code

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.