Are you ever removing your timers?

Quit Xcode, reload the project and see if the same thing happens.



> On Apr 29, 2020, at 3:36 PM, Carl Hoefs via Cocoa-dev 
> <cocoa-dev@lists.apple.com> 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];
> 
> How can this be?  NSTimeInterval is supposed to be in seconds!
> 
> From the Apple documentation:
> 
> + (NSTimer 
> <https://developer.apple.com/documentation/foundation/nstimer?language=objc> 
> *)timerWithTimeInterval:(NSTimeInterval 
> <https://developer.apple.com/documentation/foundation/nstimeinterval?language=objc>)ti
>  
>                            target:(id)aTarget 
>                          selector:(SEL)aSelector 
>                          userInfo:(id)userInfo 
>                           repeats:(BOOL)yesOrNo;
> Parameters
> ti
> The number of seconds between firings of the timer. If ti is less than or 
> equal to 0.0, this method chooses the nonnegative value of 0.0001 seconds 
> instead. A NSTimeInterval value is always specified in seconds; it yields 
> sub-millisecond precision over a range of 10,000 years.
> 
> I can accommodate this odd behavior in my code, but something's gotta be 
> wrong...
> -Carl
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> 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/zav%40mac.com
> 
> This email sent to z...@mac.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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 arch...@mail-archive.com

Reply via email to