Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
- Subject: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
- From: "Chunk 1978" <email@hidden>
- Date: Thu, 11 Dec 2008 18:00:46 -0500
thanks a lot Ashley... works great!
On Thu, Dec 11, 2008 at 2:35 PM, Ashley Clark <email@hidden> wrote:
> Sorry forgot to mention you'll probably have to cast things to integer for
> modulo to work. My compiler flags make me at least.
>
> Ashley
>
>
> On Dec 11, 2008, at 1:25 PM, Ashley Clark wrote:
>
>> 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 = (int)(remaining / 60) % 60;
>> int seconds = (int)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
>>
>
>
_______________________________________________
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>) |
| >Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining? (From: Ashley Clark <email@hidden>) |