Return to Snippet

Revision: 14123
at May 21, 2009 13:05 by bobtiki


Updated Code
- (id) init
{
	self = [super init];
	if (self != nil) {
		// If past expiration date, then pop up a dialog that says 
		// the user needs to download a new version, quit the app, and
		// load the website for new downloads
		
		NSDate *now = [NSDate date];
		NSDate *expire = [NSDate dateWithNaturalLanguageString:@"4:30pm May 19, 2009"];
		
		if ([now timeIntervalSinceReferenceDate] > [expire timeIntervalSinceReferenceDate]){
			NSLog(@"Beta Expired");
			if (NSRunAlertPanel(@"This beta of App has expired.", 
					@"Please download a new version from\nhttp://appwebsite.com.", 
					@"Go to the Download Page", @"Maybe Later", nil)) {
				[self openURL:@"http://appwebsite.com/"];
			}
			[[NSApplication sharedApplication] terminate:self];
		}
	}
	return self;
}

- (void)openURL:(NSString *)url {
	// open URL in browser
	[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:url]];	
}

Revision: 14122
at May 19, 2009 16:59 by bobtiki


Initial Code
- (id) init
{
	self = [super init];
	if (self != nil) {
		// If past expiration date, then pop up a dialog that says 
		// the user needs to download a new version, quit the app, and
		// load the website for new downloads
		
		NSDate *now = [NSDate date];
		NSDate *expire = [NSDate dateWithNaturalLanguageString:@"4:30pm May 19, 2009"];
		
		if ([now timeIntervalSinceReferenceDate] > [expire timeIntervalSinceReferenceDate]){
			NSLog(@"Beta Expired");
			if (
				NSRunAlertPanel(@"This beta of App has expired.", @"Please download a new version from\nhttp://appwebsite.com.", @"Go to the Download Page", @"Maybe Later", nil)
				
				) {
				[self openURL:@"http://appwebsite.com/"];
			}
			[[NSApplication sharedApplication] terminate:self];
		}
	}
	return self;
}

- (void)openURL:(NSString *)url {
	// open URL in browser
	[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString:url]];	
}

Initial URL


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

Initial Title
Application Expiration

Initial Tags


Initial Language
Objective C