On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev <[email protected]> wrote: > > On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev > <[email protected] <mailto:[email protected]>> wrote: >> >> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev >> <[email protected]> wrote: >>> >>> When I issue NSTimer's +timerWithTimeInterval::::: method, I'm getting >>> unexpected timer firing times (20X faster than expected). >>> >>> ∙ If I specify 1.0 for the time interval, my method gets called 20 >>> times/sec. >>> ∙ If I specify 20.0 for the time interval, my method gets called 1 time/sec. >>> ∙ If I specify 100.0 for the time interval, my method gets called 5 >>> times/sec. >>> ...etc. >>> >>> Here is my only invocation, called once and nevermore: >>> >>> NSTimer *newTimer = [NSTimer timerWithTimeInterval:1.0 // should be >>> 1/sec >>> target:self >>> selector:@selector(newData:) >>> userInfo:nil >>> repeats:YES]; >>> [[NSRunLoop mainRunLoop] addTimer:newTimer >>> forMode:NSRunLoopCommonModes]; >> >> Sounds like multiple timers are being installed. Set a breakpoint that logs >> when hit. >> > > On break, It's always the same timer. This is with time interval set to 20.0: > > <timer id> <interval> <fire date> > <__NSCFTimer: 0x60000323c600> 1.000000 Wed Apr 29 13:50:40 2020 > <__NSCFTimer: 0x60000323c600> 1.000000 Wed Apr 29 13:50:41 2020 > <__NSCFTimer: 0x60000323c600> 1.000000 Wed Apr 29 13:50:42 2020 > . . . >
I put a break directly after the creation of the timer, and introspection already shows the wrong value for the time interval! And since .timeInterval is a readonly attribute, I cannot force it to the correct value, nor is there a -setTimeInterval: method. Argh... -Carl _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
