Timers don't work?

0 views
Skip to first unread message

decarbonization

unread,
Mar 18, 2008, 9:47:11 PM3/18/08
to Programming Nu
It appears if you create an NSTimer in Nu it will only successfully
fire once, even if its repeat has been set to YES. Unless I am missing
something obvious this would definitely be a bug. Here's a test
script:

(class TestObject is NSObject
(- (void)doSomething is
(NSLog "doSomething")))

(set object (TestObject new))
(NSTimer scheduledTimerWithTimeInterval:1.0 target:object
selector:"doSomething" userInfo:nil repeats:YES)
((NSApplication sharedApplication) run)

If you run it you'll see that 'doSomething' is only logged once.

Tim

unread,
Mar 19, 2008, 2:44:42 AM3/19/08
to Programming Nu
I agree that that would be a bug, but I can't reproduce it.

Running on my MacBook Pro with 10.5.2 and a fresh build of Nu from
sources:

[Xenon:~] tim% nush decarbonization.nu
2008-03-18 23:35:32.440 nush[16414:807] doSomething
2008-03-18 23:35:33.440 nush[16414:807] doSomething
2008-03-18 23:35:34.440 nush[16414:807] doSomething
2008-03-18 23:35:35.440 nush[16414:807] doSomething
2008-03-18 23:35:36.440 nush[16414:807] doSomething
2008-03-18 23:35:37.440 nush[16414:807] doSomething
^C
[Xenon:~] tim% cat decarbonization.nu
(class TestObject is NSObject
(- (void)doSomething is
(NSLog "doSomething")))

(set object (TestObject new))
(NSTimer scheduledTimerWithTimeInterval:1.0 target:object
selector:"doSomething" userInfo:nil repeats:YES)
((NSApplication sharedApplication) run)
[Xenon:~] tim%

It also works for me with a Nu installed from the 0.3.0 dmg.

Would you confirm that you get this?
[Xenon:~] tim% nush
Nu Shell.
% YES
1

I recently moved the definition of YES from nu/cocoa.nu to the
compiled-in symbol table initialization near the end of objc/
operators.m.

Tim

decarbonization

unread,
Mar 19, 2008, 11:27:37 AM3/19/08
to Programming Nu
YES does in fact return 1. Its worth noting that although the timer
isn't firing more then once it still says its valid.
I am running the 0.3.0 install on a PPC G4 running at 867 MHz. Could
this be an architecture specific bug?

Tim Burks

unread,
Mar 19, 2008, 11:45:46 AM3/19/08
to program...@googlegroups.com

Yes, it could be a ppc-related problem, possibly related to endianness.
What happens if you pass 0xffffffff instead of YES?
You could also try 0x01000000.

Tim

decarbonization

unread,
Mar 19, 2008, 12:17:30 PM3/19/08
to Programming Nu
It appears that its actually working.

Tim

unread,
Mar 19, 2008, 1:17:59 PM3/19/08
to Programming Nu
OK, no problem. I'll check this on a G5 this evening.

Tim
Reply all
Reply to author
Forward
0 new messages