• 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: NSTimer or double to int cast (Bug?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: NSTimer or double to int cast (Bug?)
      • From: Marco Binder <email@hidden>
References: 
 >NSTimer or double to int cast (Bug?) (From: Marco Binder <email@hidden>)

  • Prev by Date: Re: Best beginner's book
  • Next by Date: Re: Best beginner's book
  • Previous by thread: NSTimer or double to int cast (Bug?)
  • Next by thread: Re: NSTimer or double to int cast (Bug?)
  • Index(es):
    • Date
    • Thread