Posted By

bobtiki on 05/19/09


Tagged

time expire app limit


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

cgrainger
bucko
Tintenklecks


Application Expiration


 / Published in: Objective C
 

Implement this in YourAppController delegate class to check for an expiration date when the app is first initialized.

  1. - (id) init
  2. {
  3. self = [super init];
  4. if (self != nil) {
  5. // If past expiration date, then pop up a dialog that says
  6. // the user needs to download a new version, quit the app, and
  7. // load the website for new downloads
  8.  
  9. NSDate *now = [NSDate date];
  10. NSDate *expire = [NSDate dateWithNaturalLanguageString:@"4:30pm May 19, 2009"];
  11.  
  12. if ([now timeIntervalSinceReferenceDate] > [expire timeIntervalSinceReferenceDate]){
  13. NSLog(@"Beta Expired");
  14. if (NSRunAlertPanel(@"This beta of App has expired.",
  15. @"Please download a new version from\nhttp://appwebsite.com.",
  16. @"Go to the Download Page", @"Maybe Later", nil)) {
  17. [self openURL:@"http://appwebsite.com/"];
  18. }
  19. [[NSApplication sharedApplication] terminate:self];
  20. }
  21. }
  22. return self;
  23. }
  24.  
  25. - (void)openURL:(NSString *)url {
  26. // open URL in browser
  27. [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:url]];
  28. }

Report this snippet  

You need to login to post a comment.