Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
Cosmic rays? Disk corruption? Tired bits? Embedded escapes? Xcode cruft? 

Whatever the bug-a-boo was, with a freshly reinstalled Xcode (11.2.1) and 
command line tools, it's gone! I blew everything away and rebuilt the project 
and It Just Works™️.

Thanks for all the support. Sorry for the noise!
-Carl

p.s. - isn't this supposed to only happen on Fridays at 5:00pm?


> On Apr 29, 2020, at 2:45 PM, Carl Hoefs  
> wrote:
> 
> When everything goes wonky... it's time to reinstall all of Xcode...!
> 
> *sigh*
> -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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Chris Walters via Cocoa-dev
I’m not suggesting you do this as any kind of real solution I just wanted to 
see if it would work, but I was able to ‘hack’ the immutable timer interval, 
perhaps something like this can help you track down what is happening.  I found 
a couple of structs in GitHub for CF source and wondered if it was possible to 
poke at the values.  As I said please don’t think I’m suggesting this as a 
fix...

// found on Github
typedef struct __MYCFRuntimeBase {
uintptr_t _cfisa;
uint8_t _cfinfo[4];
#if __LP64__
uint32_t _rc;
#endif
} MYCFRuntimeBase;

typedef struct __CFRunLoopTimer {
MYCFRuntimeBase _base;
uint16_t _bits;
pthread_mutex_t _lock;
CFRunLoopRef _runLoop;
CFMutableSetRef _rlModes;
CFAbsoluteTime _nextFireDate;
CFTimeInterval _interval;   /* immutable */
CFTimeInterval _tolerance;  /* mutable */
uint64_t _fireTSR;  /* TSR units */
CFIndex _order; /* immutable */
CFRunLoopTimerCallBack _callout;/* immutable */
CFRunLoopTimerContext _context; /* immutable, except invalidation */
} MYCFRunloopTimer;

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
NSTimer *newTimer = [NSTimer timerWithTimeInterval:1.0 // should be 1/sec
target:self selector:@selector(newData:) userInfo:nil  repeats:YES];
CFTimeInterval newTimerIntervalFromCF = CFRunLoopTimerGetInterval((__bridge 
CFRunLoopTimerRef) newTimer);

NSLog(@"CF Timer Interval: %5.2f", newTimerIntervalFromCF);
NSLog(@"Timer Interval as property: %5.2f", [newTimer timeInterval]);

// make a hacked version
MYCFRunloopTimer *myTimer = (__bridge MYCFRunloopTimer *)newTimer;
NSLog(@"Hacked TimerInterval before hacking it: %5.2f", myTimer->_interval);
myTimer->_interval = 5.0f;
NSLog(@"Hacked TimerInterval after hacking it: %5.2f", myTimer->_interval);

// See if the hacked value was set into the CF struct
newTimerIntervalFromCF = CFRunLoopTimerGetInterval((__bridge 
CFRunLoopTimerRef) newTimer);

NSLog(@"After hack CF Timer Interval: %5.2f", newTimerIntervalFromCF);
NSLog(@"After hack timer Interval as property: %5.2f", [newTimer 
timeInterval]);

[[NSRunLoop mainRunLoop] addTimer:newTimer forMode:NSRunLoopCommonModes];
}

- (void) newData:(NSTimer *)timer {
NSLog(@"timer is %@", timer);
}

2020-04-30 00:00:19.372 TestTimer[8777:362408] CF Timer Interval:  1.00
2020-04-30 00:00:19.372 TestTimer[8777:362408] Timer Interval as property:  1.00
2020-04-30 00:00:19.372 TestTimer[8777:362408] Hacked TimerInterval before 
hacking it:  1.00
2020-04-30 00:00:19.372 TestTimer[8777:362408] Hacked TimerInterval after 
hacking it:  5.00
2020-04-30 00:00:19.372 TestTimer[8777:362408] After hack CF Timer Interval:  
5.00
2020-04-30 00:00:19.372 TestTimer[8777:362408] After hack timer Interval as 
property:  5.00
2020-04-30 00:00:20.372 TestTimer[8777:362408] timer is <__NSCFTimer: 
0x7fd1fa45f550>
2020-04-30 00:00:25.373 TestTimer[8777:362408] timer is <__NSCFTimer: 
0x7fd1fa45f550>
2020-04-30 00:00:30.372 TestTimer[8777:362408] timer is <__NSCFTimer: 
0x7fd1fa45f550>
2020-04-30 00:00:35.372 TestTimer[8777:362408] timer is <__NSCFTimer: 
0x7fd1fa45f550>
2020-04-30 00:00:40.371 TestTimer[8777:362408] timer is <__NSCFTimer: 
0x7fd1fa45f550>


> On 29 Apr 2020, at 23:51, Ken Thomases via Cocoa-dev 
>  wrote:
> 
> Does this happen only when launched from Xcode, or also when launched 
> normally?  Does this happen with a different user account?  Does it happen 
> when run on another Mac?
> 
> -Ken
> 
>> On Apr 29, 2020, at 4:35 PM, Carl Hoefs via Cocoa-dev 
>>  wrote:
>> 
>> There are no extensions or categories in the project. 
>> I changed the -newData: method name to -arrivalOfNewData:. 
>> I changed the newTimer variable name to theTimer. 
>> I rebooted the machine. 
>> 
>> No joy.
>> 
>> I realize this is no longer a Cocoa problem, but what - even theoretically - 
>> could cause this? 
>> As shown in the debugger, the timer gets created with the wrong time 
>> interval value, by a consistent factor of 20.
>> 
>> -Carl
>> 
>> 
>>> On Apr 29, 2020, at 2:24 PM, Andy Lee  wrote:
>>> 
>>> I did the same just now in a macOS project.  Copied your code and added a 
>>> newData: method.  This is with Xcode 11.2.1 on Mojave, 10.4.6.  Works fine 
>>> for me.  Weird!
>>> 
>>> @implementation AppDelegate
>>> 
>>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>>>   NSTimer *newTimer = [NSTimer timerWithTimeInterval:1.0  // should be 1/sec
>>>   target:self
>>> selector:@selector(newData:)
>>> userInfo:nil
>>>  repeats:YES];
>>>   [[NSRunLoop mainRunLoop] addTimer:newTimer
>>> for

Re: [OT] NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Sandor, it’s somewhere in the naming guide for the Objectice-C fundamental 
docs.  I could be confusing things though.

> On Apr 29, 2020, at 5:27 PM, Sandor Szatmari  
> wrote:
> 
> Alex,
> 
>> On Apr 29, 2020, at 17:12, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> Not sure about this, but in Objective-C, you’re not supposed to start 
>> methods with new.
> 
> I’ve always operated under the premise that using a reserved prefix, such as 
> new, was not verboten.  Rather, if one chose the prefix new one must ensure 
> that the method followed memory management conventions, and would return an 
> object with a +1 retain count.  Am I mistaken about this?
> 
> Sandor
> 
>> 
 On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
  wrote:
>> 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];
>> 
>> ___
>> 
>> 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/admin.szatmari.net%40gmail.com
>> 
>> This email sent to admin.szatmari@gmail.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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Ken Thomases via Cocoa-dev
Does this happen only when launched from Xcode, or also when launched normally? 
 Does this happen with a different user account?  Does it happen when run on 
another Mac?

-Ken

> On Apr 29, 2020, at 4:35 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> There are no extensions or categories in the project. 
> I changed the -newData: method name to -arrivalOfNewData:. 
> I changed the newTimer variable name to theTimer. 
> I rebooted the machine. 
> 
> No joy.
> 
> I realize this is no longer a Cocoa problem, but what - even theoretically - 
> could cause this? 
> As shown in the debugger, the timer gets created with the wrong time interval 
> value, by a consistent factor of 20.
> 
> -Carl
> 
> 
>> On Apr 29, 2020, at 2:24 PM, Andy Lee  wrote:
>> 
>> I did the same just now in a macOS project.  Copied your code and added a 
>> newData: method.  This is with Xcode 11.2.1 on Mojave, 10.4.6.  Works fine 
>> for me.  Weird!
>> 
>> @implementation AppDelegate
>> 
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>>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];
>> }
>> 
>> - (void)newData:(NSTimer *)timer {
>>NSLog(@"timer is %@", timer);
>> }
>> 
>> @end
>> 
>> 2020-04-29 17:20:45.331469-0400 NSTimerQuestion[21676:3985041] Metal API 
>> Validation Enabled
>> 2020-04-29 17:20:46.413190-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:47.412968-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:48.413525-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:49.413373-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:50.412610-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> ...
>> 
>> --Andy
>> 
>> On Apr 29, 2020, at 5:15 PM, Alex Zavatone via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> I used your code in an iOS project and it works as expected.
>>> 
>>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>>> 2020
>>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>>> 2020
>>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>>> 2020
>>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>>> 2020
>>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>>> 2020
>>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>>> 2020
>>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>>> 2020
>>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>>> 2020
>>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>>> 2020
>>> 
>>> I’ll mail you the project offlist.
>>> 
>>> 
>>> 
 On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com>> wrote:
 
 On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com>> wrote:
> 
> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com> 
> >> 
> wrote:
>> 
>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>> mailto: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];
>> 
>> Sounds like multiple timers are being installed. Set a breakpoint that 
>> logs when hit.
>>

Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread John Bishop via Cocoa-dev
The documentation indicates "... for a repeating timer, you must invalidate the 
time object yourself by calling its invalidate method.  Calling this method 
requests the removal of the timer from the current run loop; as a result, you 
should always call the invalidate method from the same thread on which the 
timer was installed.  Invalidating the timer immediately disables it so that it 
no longer affects the run loop.  The run loop then removes the timer (and the 
strong reference it had to the timer), either just before the invalidate method 
returns or at some later point."

> ? If I specify 100.0 for the time interval, my method gets called 5 times/sec.
I think you meant: "my method gets called every 5 seconds"  I'm also in 
agreement that you might have more timers than you think, but I can be swayed.

Try it with scheduledTimerWithTimeInterval: and instrument its creation (NSLog 
or equiv.) which might help debug whether its the timer or how it's added or 
perhaps how the caller is threaded...

@property (nonatomic, assign) NSTimer *myOneSecondTimer;

[self.myOneSecondTimer invalidate];
self.myOneSecondTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self  selector:@selector(newData:)  userInfo nil  
repeats:YES];

> On Apr 29, 2020, at 4:35 PM, cocoa-dev-requ...@lists.apple.com wrote:
> 
> Subject: NSTimer +timerWithTimeInterval:
> Message-ID:
>   
> Content-Type: text/plain; charset=utf-8
> 
> 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 
>  
> *)timerWithTimeInterval:(NSTimeInterval 
> )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
> 

--
John Bishop
Mulligan Software


___

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


Re: [OT] Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Ken Thomases via Cocoa-dev
On Apr 29, 2020, at 5:27 PM, Sandor Szatmari via Cocoa-dev 
 wrote:
> 
>> On Apr 29, 2020, at 17:12, Alex Zavatone via Cocoa-dev 
>>  wrote:
>> 
>> Not sure about this, but in Objective-C, you’re not supposed to start 
>> methods with new.
> 
> I’ve always operated under the premise that using a reserved prefix, such as 
> new, was not verboten.  Rather, if one chose the prefix new one must ensure 
> that the method followed memory management conventions, and would return an 
> object with a +1 retain count.  Am I mistaken about this?

No, you're not mistaken.  That's correct.

Regards,
Ken

___

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


[OT] Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Sandor Szatmari via Cocoa-dev
Alex,

> On Apr 29, 2020, at 17:12, Alex Zavatone via Cocoa-dev 
>  wrote:
> 
> Not sure about this, but in Objective-C, you’re not supposed to start 
> methods with new.

I’ve always operated under the premise that using a reserved prefix, such as 
new, was not verboten.  Rather, if one chose the prefix new one must ensure 
that the method followed memory management conventions, and would return an 
object with a +1 retain count.  Am I mistaken about this?

Sandor

> 
>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>>  wrote:
> 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];
> 
> ___
> 
> 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/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Keary Suska via Cocoa-dev
Are the timer values actual numeric constants, or a variable defined earlier in 
code?

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

> On Apr 29, 2020, at 3:35 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> There are no extensions or categories in the project. 
> I changed the -newData: method name to -arrivalOfNewData:. 
> I changed the newTimer variable name to theTimer. 
> I rebooted the machine. 
> 
> No joy.
> 
> I realize this is no longer a Cocoa problem, but what - even theoretically - 
> could cause this? 
> As shown in the debugger, the timer gets created with the wrong time interval 
> value, by a consistent factor of 20.
> 
> -Carl
> 
> 
>> On Apr 29, 2020, at 2:24 PM, Andy Lee  wrote:
>> 
>> I did the same just now in a macOS project.  Copied your code and added a 
>> newData: method.  This is with Xcode 11.2.1 on Mojave, 10.4.6.  Works fine 
>> for me.  Weird!
>> 
>> @implementation AppDelegate
>> 
>> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
>>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];
>> }
>> 
>> - (void)newData:(NSTimer *)timer {
>>NSLog(@"timer is %@", timer);
>> }
>> 
>> @end
>> 
>> 2020-04-29 17:20:45.331469-0400 NSTimerQuestion[21676:3985041] Metal API 
>> Validation Enabled
>> 2020-04-29 17:20:46.413190-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:47.412968-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:48.413525-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:49.413373-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> 2020-04-29 17:20:50.412610-0400 NSTimerQuestion[21676:3985041] timer is 
>> <__NSCFTimer: 0x6370eb80>
>> ...
>> 
>> --Andy
>> 
>> On Apr 29, 2020, at 5:15 PM, Alex Zavatone via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> I used your code in an iOS project and it works as expected.
>>> 
>>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>>> 2020
>>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>>> 2020
>>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>>> 2020
>>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>>> 2020
>>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>>> 2020
>>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>>> 2020
>>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>>> 2020
>>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>>> 2020
>>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>>> 2020
>>> 
>>> I’ll mail you the project offlist.
>>> 
>>> 
>>> 
 On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com>> wrote:
 
 On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com>> wrote:
> 
> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com> 
> >> 
> wrote:
>> 
>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>> mailto: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];
>> 
>> Sounds like multiple timers are being installed. Set a breakpoint that 
>> logs when hit.
>> 
>>

Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
For giggles, comment out the current code and replace it with exactly the same 
code.  Or put it in a new class and call the new class.



> On Apr 29, 2020, at 4:45 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> When everything goes wonky... it's time to reinstall all of Xcode...!
> 
> *sigh*
> -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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Rob Petrovec via Cocoa-dev
I thought when everything goes wonky you zap the PRAM and rebuild the Desktop?

—Rob


> On Apr 29, 2020, at 3:45 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> When everything goes wonky... it's time to reinstall all of Xcode...!
> 
> *sigh*
> -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/petrock%40mac.com
> 
> This email sent to petr...@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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
When everything goes wonky... it's time to reinstall all of Xcode...!

*sigh*
-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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
There are no extensions or categories in the project. 
I changed the -newData: method name to -arrivalOfNewData:. 
I changed the newTimer variable name to theTimer. 
I rebooted the machine. 

No joy.

I realize this is no longer a Cocoa problem, but what - even theoretically - 
could cause this? 
As shown in the debugger, the timer gets created with the wrong time interval 
value, by a consistent factor of 20.

-Carl


> On Apr 29, 2020, at 2:24 PM, Andy Lee  wrote:
> 
> I did the same just now in a macOS project.  Copied your code and added a 
> newData: method.  This is with Xcode 11.2.1 on Mojave, 10.4.6.  Works fine 
> for me.  Weird!
> 
> @implementation AppDelegate
> 
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
> 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];
> }
> 
> - (void)newData:(NSTimer *)timer {
> NSLog(@"timer is %@", timer);
> }
> 
> @end
> 
> 2020-04-29 17:20:45.331469-0400 NSTimerQuestion[21676:3985041] Metal API 
> Validation Enabled
> 2020-04-29 17:20:46.413190-0400 NSTimerQuestion[21676:3985041] timer is 
> <__NSCFTimer: 0x6370eb80>
> 2020-04-29 17:20:47.412968-0400 NSTimerQuestion[21676:3985041] timer is 
> <__NSCFTimer: 0x6370eb80>
> 2020-04-29 17:20:48.413525-0400 NSTimerQuestion[21676:3985041] timer is 
> <__NSCFTimer: 0x6370eb80>
> 2020-04-29 17:20:49.413373-0400 NSTimerQuestion[21676:3985041] timer is 
> <__NSCFTimer: 0x6370eb80>
> 2020-04-29 17:20:50.412610-0400 NSTimerQuestion[21676:3985041] timer is 
> <__NSCFTimer: 0x6370eb80>
> ...
> 
> --Andy
> 
> On Apr 29, 2020, at 5:15 PM, Alex Zavatone via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> I used your code in an iOS project and it works as expected.
>> 
>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>> 2020
>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>> 2020
>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>> 2020
>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>> 2020
>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>> 2020
>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>> 2020
>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>> 2020
>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>> 2020
>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>> 2020
>> 
>> I’ll mail you the project offlist.
>> 
>> 
>> 
>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
 
 On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com> 
 >> 
 wrote:
> 
> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
> mailto: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];
> 
> 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:
 
   
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:42 2020
 . . .
>>

Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Just ot be safe, reboot your Mac to make sure that things aren’t completely 
borked.  I’ve had to do this many times.  

> On Apr 29, 2020, at 4:26 PM, Carl Hoefs  
> wrote:
> 
> I accept that NSTimer works as documented! But I allege there must be 
> something odd about my (inherited) project that I can't quite put my finger 
> on.
> 
> Perhaps the +timerWithTimeInterval: method is overridden...
> -Carl
> 
> 
>> On Apr 29, 2020, at 2:15 PM, Alex Zavatone > > wrote:
>> 
>> I used your code in an iOS project and it works as expected.
>> 
>> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 
>> 2020
>> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 
>> 2020
>> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 
>> 2020
>> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 
>> 2020
>> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 
>> 2020
>> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 
>> 2020
>> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 
>> 2020
>> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 
>> 2020
>> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 
>> 2020
>> 
>> I’ll mail you the project offlist.
>> 
>> 
>> 
>>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com>> wrote:
 
 On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
 mailto:cocoa-dev@lists.apple.com> 
 >> 
 wrote:
> 
> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
> mailto: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];
> 
> 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:
 
   
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
 <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
 <__NSCFTimer: 0x6323c600>   1.00   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 (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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
I accept that NSTimer works as documented! But I allege there must be something 
odd about my (inherited) project that I can't quite put my finger on.

Perhaps the +timerWithTimeInterval: method is overridden...
-Carl


> On Apr 29, 2020, at 2:15 PM, Alex Zavatone  wrote:
> 
> I used your code in an iOS project and it works as expected.
> 
> 2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 2020
> 2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 2020
> 2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 2020
> 2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 2020
> 2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 2020
> 2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 2020
> 2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 2020
> 2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 2020
> 2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 2020
> 
> I’ll mail you the project offlist.
> 
> 
> 
>> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
>>> mailto:cocoa-dev@lists.apple.com> 
>>> >> 
>>> wrote:
 
 On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
 mailto: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];
 
 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:
>>> 
>>>   
>>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
>>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
>>> <__NSCFTimer: 0x6323c600>   1.00   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 (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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
I used your code in an iOS project and it works as expected.

2020-04-29 16:14:02.254107-0500 Timer[83275:13268128] Wed Apr 29 16:14:02 2020
2020-04-29 16:14:03.254048-0500 Timer[83275:13268128] Wed Apr 29 16:14:03 2020
2020-04-29 16:14:04.253957-0500 Timer[83275:13268128] Wed Apr 29 16:14:04 2020
2020-04-29 16:14:05.254170-0500 Timer[83275:13268128] Wed Apr 29 16:14:05 2020
2020-04-29 16:14:06.254490-0500 Timer[83275:13268128] Wed Apr 29 16:14:06 2020
2020-04-29 16:14:07.254570-0500 Timer[83275:13268128] Wed Apr 29 16:14:07 2020
2020-04-29 16:14:08.254651-0500 Timer[83275:13268128] Wed Apr 29 16:14:08 2020
2020-04-29 16:14:09.253715-0500 Timer[83275:13268128] Wed Apr 29 16:14:09 2020
2020-04-29 16:14:10.254741-0500 Timer[83275:13268128] Wed Apr 29 16:14:10 2020

I’ll mail you the project offlist.



> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
> On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
>> 
>> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
>> mailto:cocoa-dev@lists.apple.com>> wrote:
>>> 
>>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>>>  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:
>> 
>>   
>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
>> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
>> <__NSCFTimer: 0x6323c600>   1.00   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 (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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
Not sure about this, but in Objective-C, you’re not supposed to start methods 
with new.

> On Apr 29, 2020, at 4:07 PM, Carl Hoefs via Cocoa-dev 
>  wrote:
> 
 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];

___

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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
On Apr 29, 2020, at 1:53 PM, Carl Hoefs via Cocoa-dev 
 wrote:
> 
> On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
> mailto:cocoa-dev@lists.apple.com>> wrote:
>> 
>> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>>  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:
> 
>
> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
> <__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
> <__NSCFTimer: 0x6323c600>   1.00   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 (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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
On Apr 29, 2020, at 1:43 PM, Steve Mills via Cocoa-dev 
 wrote:
> 
> On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
>  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:


<__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:40 2020
<__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:41 2020
<__NSCFTimer: 0x6323c600>   1.00   Wed Apr 29 13:50:42 2020
. . .

-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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Steve Mills via Cocoa-dev
On Apr 29, 2020, at 15:36:23, Carl Hoefs via Cocoa-dev 
 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.

--
Steve Mills
Drummer, Mac geek

___

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


Re: NSTimer +timerWithTimeInterval:

2020-04-29 Thread Alex Zavatone via Cocoa-dev
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 
>  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 
>  
> *)timerWithTimeInterval:(NSTimeInterval 
> )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


NSTimer +timerWithTimeInterval:

2020-04-29 Thread Carl Hoefs via Cocoa-dev
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 
 
*)timerWithTimeInterval:(NSTimeInterval 
)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/archive%40mail-archive.com

This email sent to arch...@mail-archive.com