Re: NSTimer or double to int cast (Bug?)
Re: NSTimer or double to int cast (Bug?)
- Subject: Re: NSTimer or double to int cast (Bug?)
- From: Cameron Hayne <email@hidden>
- Date: Fri, 10 Jan 2003 02:55:56 -0500
On 9/1/03 1:50 pm, "Marco Binder" <email@hidden> wrote:
>
I made a simple countdown app on my G4,
>
using a simple NSTimer (countDown), firing every 1.0 seconds. However:
>
> double interval = [countDown timeInterval];
>
> NSLog(@"time interval: %f, rounded: %d",interval,(int)interval);
>
the above code gives, correctly on my G4:
>
> 2003-01-09 16:55:56.750 CountDownApp[697] time interval: 1.000000,
>
> rounded: 1
>
But when running the app on an iMac G3 or my iBook (G3 obviously), it
>
results in:
>
> 2003-01-09 16:58:20.832 CountDownApp[697] time interval: 1.000000,
>
> rounded: 0
I cannot reproduce your problem on my iBook. I create a timer with:
double interval = 1.0;
NSTimer *timer = [NSTimer
scheduledTimerWithTimeInterval: interval
target: self
selector: @selector(timeGentlemen:)
userInfo: nil
repeats: YES];
and then the method:
+ (void)timeGentlemen:(NSTimer *)theTimer
{
NSLog(@"It is now %@", [[NSDate date] description]);
double value = [theTimer timeInterval];
NSLog(@"%f %d", value, (int)value);
}
prints out:
1.000000 1
every time.
--
Cameron Hayne (email@hidden)
Hayne of Tintagel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.