Skip navigation.
 
mlRe: MacOSX-dev Digest, Vol 16, Issue 10
FROM : Power Mac User
DATE : Fri Apr 08 21:16:53 2005

On Apr 8, 2005, at 11:16 AM, <email_removed> wrote:

> Hello out there,
>
> Does anybody know, how to deactivate a software after a certain
> test/trial period, so that after this time the apllication won't
> launch anymore?
>
> Could someone support me with source-code (for cocoa/obj.C) for this
> issue.
>
> Thanks in advance!!!!
>
> DH
>


Hello!

Perhaps you can use NSUserDefaults.

#define YOUREXPIRATIONPERIOD // NSTimeInterval which is a double

+ (void)initialize
{
   NSMutableDictionary *defaultValues = [NSMutableDictionary dictionary];
   
   [defaultValues setObject:[NSDate date] forKey:@"AppInstallationDate"];
   [[NSUserDefaults standardUserDefaults] registerDefaults:defaultValues];
}

Then in your NSApp delegate's applicationWillFinishLaunching:

- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
   NSDate *installDate = [[NSUserDefaults standardUserDefaults]
objectForKey:@"AppInstallationDate"];
   
   if (  [[install date] timeIntervalSinceNow] > YOUREXPIRATIONPERIOD )
   {
       // Possibly insert a NSAlert
       [NSApp terminate:nil]
   }
}

Regards,

<email_removed>

Related mailsAuthorDate
mlRe: MacOSX-dev Digest, Vol 16, Issue 10 Power Mac User Apr 8, 21:16
mlRe: MacOSX-dev Digest, Vol 16, Issue 10 John Brownlow Apr 8, 21:24
mlRe: MacOSX-dev Digest, Vol 16, Issue 10 Lon Varscsak Apr 8, 21:31