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.
The former code (http://snipplr.com/view/3448/kill-app-after-expire-date/) was not internationalised and might cause an issue when run outside of English speaking countries. This code resolves the locale issue.
- // Based on original code by Daniel Jakult, based on an idea from Brian Cooke.
- #ifdef BETA // 4 week expiration
- #define EXPIREAFTERDAYS 28
- #if EXPIREAFTERDAYS
- [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
- [dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@”en_US”]
- [dateFormatter setDateFormat:@"MMM dd yyyy"];
- NSDate *compileDate = [dateFormatter dateFromString:compileDateString];
- [dateFormatter release];
- NSDate *expireDate = [compileDate addTimeInterval:(60*60*24* EXPIREAFTERDAYS)];
- if ([expireDate earlierDate:[NSDate date]] == expireDate)
- // Run an alert or whatever
- // Quit!
- [NSApp terminate:self];
You need to login to post a comment.