• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?


  • Subject: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • From: Ashley Clark <email@hidden>
  • Date: Thu, 11 Dec 2008 13:25:25 -0600

On Dec 11, 2008, at 6:32 AM, Chunk 1978 wrote:

thanks everyone for the answers.

i agree that Ashley's method is far more readable than using modulus
calculations, so i'll look into that further as i can't seem to get it
working yet.

currently, i have this working using modulus calculations, but it
starts at 00 for the hours and minutes...

/* snip */

- (void)updateTime:(NSTimer *)theTimer
	{
	NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
	NSTimeInterval interval = now - startTime;

	//Tag #1 x 3600 Seconds = 3600 Seconds = 2 Hours.
	//Tag #2 x 3600 Seconds = 7200 Seconds = 2 Hours.
	//Tag #3 x 3600 Seconds = 10800 Seconds = 3 Hours.

int hoursSelected = ([self timeMenuSelection] * 3600);

NSTimeInterval remaining = hoursSelected - second;

if (remaining >= 0)
	{
	int hours = remaining / 3600;
	int minutes = (remaining / 60) % 60;
	int seconds = remaining % 60;

	NSLog(@"%.2d %.2d %.2d ", hours, minutes, seconds);

		}
		else
		{
		NSLog(@"TIME'S UP!");
		[killTimer invalidate];
		[killTimer release];
		killTimer = nil;
		}
	}
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: "Chunk 1978" <email@hidden>)
 >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: Ashley Clark <email@hidden>)
 >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: "Chunk 1978" <email@hidden>)
 >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: Nick Zitzmann <email@hidden>)
 >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: Ashley Clark <email@hidden>)
 >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: "Chunk 1978" <email@hidden>)

  • Prev by Date: Is it useful to make a 64 bit app? [Was]: How can users check if their mac is 64-bit-capable?
  • Next by Date: Re: Resizing an image
  • Previous by thread: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • Next by thread: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • Index(es):
    • Date
    • Thread