Revision: 3505
Updated Code
at July 9, 2008 22:41 by zingo
Updated Code
// For a internationalised version // see: http://snipplr.com/view/7196/kill-app-after-expire-date-suicidal-code-redux/ // Two-week expiration #define EXPIREAFTERDAYS 14 #if EXPIREAFTERDAYS // Idea from Brian Cooke. NSString* nowString = [NSString stringWithUTF8String:__DATE__]; NSCalendarDate* nowDate = [NSCalendarDate dateWithNaturalLanguageString:nowString]; NSCalendarDate* expireDate = [nowDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)]; if ([expireDate earlierDate:[NSDate date]] == expireDate) { // Run an alert or whatever // Quit! [NSApp terminate:self]; } #endif
Revision: 3504
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 3, 2007 22:48 by zingo
Initial Code
// Two-week expiration #define EXPIREAFTERDAYS 14 #if EXPIREAFTERDAYS // Idea from Brian Cooke. NSString* nowString = [NSString stringWithUTF8String:__DATE__]; NSCalendarDate* nowDate = [NSCalendarDate dateWithNaturalLanguageString:nowString]; NSCalendarDate* expireDate = [nowDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)]; if ([expireDate earlierDate:[NSDate date]] == expireDate) { // Run an alert or whatever // Quit! [NSApp terminate:self]; } #endif
Initial URL
http://www.red-sweater.com/blog/371/suicidal-code
Initial Description
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/
Initial Title
kill app after expire date
Initial Tags
osx
Initial Language
Objective C