Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Mac OS X Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-02-2010, 10:58 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 69
Default Self terminating beta code

hey guys, im taking a dip into OSX developing and im making fair progress in my first few apps for both iphone os and osx, but i was wondering if theres something i can put in the code that makes the current beta build run for only a few days, and after those days the app refuses to launch.

Id rather it be a time limit as opposed to a certain number of runs, but whatever is more practical will work

THANKS GUYS!!
truehybridx is offline   Reply With Quote
Old 01-03-2010, 08:43 AM   #2 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

When it launches, check the date, if it's past the expiry date, show a little message explaining, then quit.

Tom
harrytheshark is offline   Reply With Quote
Old 01-03-2010, 12:24 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 69
Default

would you mind giving some sample code on doing this?
truehybridx is offline   Reply With Quote
Old 01-03-2010, 12:59 PM   #4 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

No problem,
Code:
NSDateFormatter * newFormatter = [[NSDateFormatter alloc] init];
[newFormatter setDateFormat:@"dd mm yyyy"];
	
NSDate * endDate = [newFormatter dateFromString:@"04 01 2010"]; //This is the end date, this is what we're checking for
[newFormatter release];
	
NSDate * nowDate = [NSDate date];
	
if ([nowDate compare:endDate] == NSOrderedDescending){
   NSLog(@"expired");
   //Show message, then quit
}
else
{
   NSLog(@"nope, still good");
   //It hasn't expired yet.
}
I created endDate in the way shown above just as a quick example and doesn't have a time or anything, just a date. The important bit is the comparison to see if the endDate has passed.

Tom
harrytheshark is offline   Reply With Quote
Old 01-03-2010, 02:34 PM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 69
Default

Quote:
Originally Posted by harrytheshark View Post
No problem,
Code:
NSDateFormatter * newFormatter = [[NSDateFormatter alloc] init];
[newFormatter setDateFormat:@"dd mm yyyy"];
	
NSDate * endDate = [newFormatter dateFromString:@"04 01 2010"]; //This is the end date, this is what we're checking for
[newFormatter release];
	
NSDate * nowDate = [NSDate date];
	
if ([nowDate compare:endDate] == NSOrderedDescending){
   NSLog(@"expired");
   //Show message, then quit
}
else
{
   NSLog(@"nope, still good");
   //It hasn't expired yet.
}
I created endDate in the way shown above just as a quick example and doesn't have a time or anything, just a date. The important bit is the comparison to see if the endDate has passed.

Tom
so if i know my stuff right, i would pop this into the applicationDidFinishLaunching method? or is that only in the iphone version?

also how do you make the app quit? on both OSX and iphoneOS
truehybridx is offline   Reply With Quote
Old 01-03-2010, 02:36 PM   #6 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Yeah, that's right.

I think you can quit both by doing
Code:
exit();
But I'm not 100% sure.

Tom
harrytheshark is offline   Reply With Quote
Old 01-03-2010, 03:14 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 69
Default

Code:
applicationDidFinishLaunching()
doesnt get called or something but the best way i found to kill an app in osx is
Code:
[[NSApplication sharedApplication] terminate: nil];
ok i never set the .m i was using to delagate the method so it was never working right, BUT now it does yay!! thank ya~!!

Last edited by truehybridx; 01-03-2010 at 03:33 PM. Reason: correction x2 lol
truehybridx is offline   Reply With Quote
Old 02-12-2010, 03:35 PM   #8 (permalink)
Registered Member
 
Join Date: Dec 2008
Location: UK
Posts: 1,886
Default

Code:
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification {

}
Is available on Mac OS X
harrytheshark is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 256
13 members and 243 guests
2WeeksToGo, AdamL, ADY, BrianSlick, Dani77, Dattee, headkaze, mer10, mgon987, timle8n1, Touchmint, vigu360
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,879
Threads: 89,228
Posts: 380,745
Top Poster: BrianSlick (7,129)
Welcome to our newest member, mgon987
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:47 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0