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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-11-2010, 03:31 PM   #1 (permalink)
New to the SDK
 
franzwarning's Avatar
 
Join Date: Jul 2010
Location: Portland, Oregon
Age: 19
Posts: 165
franzwarning is on a distinguished road
Send a message via AIM to franzwarning Send a message via Skype™ to franzwarning
Default How to make a button available once a day.

Hello,

How could i make a button available only once a day?

Cheers,
George
franzwarning is offline   Reply With Quote
Old 09-11-2010, 06:45 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 577
Speed is on a distinguished road
Default

Quote:
Originally Posted by franzwarning View Post
Hello,

How could i make a button available only once a day?

Cheers,
George
Here is what I used to check it if it was over a day since the last visit:

Declare difference as an NSTimeInterval. This is my code that I used and it may not work for you but it should give you a push in the correct direction.

Code:
-(void)viewDidLoad {
	NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
	
	NSTimeInterval date = [defaults doubleForKey:@"startTimeInterval"];
	
	NSTimeInterval dateNow = [NSDate timeIntervalSinceReferenceDate];
	
	difference = dateNow - date;
	
	difference = difference / 84000;
	
	if(difference >= 0 && difference <= 1) {

button.enabled = NO;
		
	}	
	
	if(difference >= 1 ) {
		dateNow = [NSDate timeIntervalSinceReferenceDate];
		[defaults setDouble:dateNow forKey:@"startTimeInterval"];
		[defaults synchronize];
button.enabled = YES;
	}	
}
It find the amount of seconds since the last time, then divides it by 84000 which is the amount of seconds in a day so you get a decimal number with the amount of days since. If it is greater than 1, it sets the current date, if it is less than 1 day, it doesn't re-set the current date. Again, this is untested as I ripped it from another app of mine, but you should get the picture I think.
Speed is offline   Reply With Quote
Old 09-11-2010, 06:50 PM   #3 (permalink)
New to the SDK
 
franzwarning's Avatar
 
Join Date: Jul 2010
Location: Portland, Oregon
Age: 19
Posts: 165
franzwarning is on a distinguished road
Send a message via AIM to franzwarning Send a message via Skype™ to franzwarning
Default

Thanks so much that really helped!
franzwarning 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: 343
13 members and 330 guests
bignoggins, carlandrews, cgokey, givensur, hzwegjxg, iGamesDev, jenniead38, linkmx, mraalex, PixelInteractive, raihan.zbr, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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