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: Chris Ridd <email@hidden>
- Date: Fri, 10 Jan 2003 15:49:50 +0000
On 10/1/03 1:05 pm, Marco Binder <email@hidden> wrote:
>
OK, I set up a new project and copied the relevant lines. The whole
>
project looks like this:
>
>
@implementation Controller
>
>
- (id) init {
>
if (self = [super init]) {
>
double interval = 1.0;
>
timer = [[NSTimer scheduledTimerWithTimeInterval:interval
>
target:self selector:@selector(timerAction:) userInfo:nil repeats:YES]
>
retain];
>
}
>
return self;
>
}
>
>
- (void) timerAction: (id) sender {
>
NSLog(@"- interval as returned: %f, interval as int: %d",[timer
>
timeInterval], (int)[timer timeInterval]);
>
}
>
>
@end
>
>
Maybe there is something wrong with the code, but I dont see it. And as
>
before, this code results in the following being written to the console
>
on my G4:
>
>
## Component Manager: attempting to find symbols in a component alias
>
of type (regR/carP/x!bt)
>
2003-01-10 13:58:04.390 TimerTest[834] - interval as returned:
>
1.000000, interval as int: 1
>
2003-01-10 13:58:05.389 TimerTest[834] - interval as returned:
>
1.000000, interval as int: 1
>
2003-01-10 13:58:06.389 TimerTest[834] - interval as returned:
>
1.000000, interval as int: 1
>
>
On the other hand on the G3 iBook:
>
>
2003-01-10 14:00:37.286 TimerTest[413] - interval as returned:
>
1.000000, interval as int: 0
>
2003-01-10 14:00:38.284 TimerTest[413] - interval as returned:
>
1.000000, interval as int: 0
>
2003-01-10 14:00:39.283 TimerTest[413] - interval as returned:
>
1.000000, interval as int: 0
>
>
I am not making this up, and you are more than welcome to downlad the
>
project at: http://www.sb-software.de/TimerTest.tgz
>
>
>
I still think this is extremly strange and would appreciate any kind of
>
explaination.
>
>
>
marco
You're passing a double to NSLog but only using the %f (float) format
specifier. That doesn't address the fact that value does seem to be less
than 1, but it might be worth seeing if using %lf made a difference.
Cheers,
Chris
_______________________________________________
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.