Congratulations MacRuby Development Team: My application almost runs now in MacRuby. Is NSTimer class supported in MacRuby? I was doing background processing using NSTimer as follows: @timer = NSTimer.scheduledTimerWithTimeInterval( 5.0, :target, self, :selector, :periodicUpdate, :userInfo, nil, :repeats, true ) but this now gives me the error: undefined method `scheduledTimerWithTimeInterval' for NSTimer:Class (NoMethodError) Do you have a preferred method for doing backgound tasks in MacRuby - perhaps separate threads? Thanks, Bob Rice
Hi Bob, (you are going to kick yourself) you have misplaced the colon between target and self - there is a comma there, and the colon has been placed in front of "target", so the method is not being recognised. eg: @synchro_timer = NSTimer.scheduledTimerWithTimeInterval(TIME_INTERVAL, target:self, selector:"synchronise_with_server:", userInfo:nil, repeats:true) as for threads - maybe someone else could chime in with a preference - but I do it the Cocoa way (eg http Connection delegates or timers) - but for data crunching using all cores I will use something like Laurent's barber shop code: http://www.macruby.org/blog/2009/10/07/macruby05b1.html . J On Oct 11, 2009, at 6:19 PM, Robert Rice wrote:
Congratulations MacRuby Development Team:
My application almost runs now in MacRuby.
Is NSTimer class supported in MacRuby?
I was doing background processing using NSTimer as follows:
@timer = NSTimer.scheduledTimerWithTimeInterval( 5.0, :target, self, :selector, :periodicUpdate, :userInfo, nil, :repeats, true )
but this now gives me the error:
undefined method `scheduledTimerWithTimeInterval' for NSTimer:Class (NoMethodError)
Do you have a preferred method for doing backgound tasks in MacRuby - perhaps separate threads?
Thanks, Bob Rice
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks John:: I wasn't familiar with this new syntax. I was using the old syntax "NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats " but I see it doesn't work in MacRuby. MarRuby is giving me error messages without a traceback. Is there a way to enable tracebacks? Bob Rice On Oct 11, 2009, at 12:58 PM, John Shea wrote:
Hi Bob,
(you are going to kick yourself) you have misplaced the colon between target and self - there is a comma there, and the colon has been placed in front of "target", so the method is not being recognised.
eg: @synchro_timer = NSTimer.scheduledTimerWithTimeInterval (TIME_INTERVAL, target:self, selector:"synchronise_with_server:", userInfo:nil, repeats:true)
as for threads - maybe someone else could chime in with a preference - but I do it the Cocoa way (eg http Connection delegates or timers) - but for data crunching using all cores I will use something like Laurent's barber shop code: http://www.macruby.org/blog/2009/10/07/macruby05b1.html .
J
On Oct 11, 2009, at 6:19 PM, Robert Rice wrote:
Congratulations MacRuby Development Team:
My application almost runs now in MacRuby.
Is NSTimer class supported in MacRuby?
I was doing background processing using NSTimer as follows:
@timer = NSTimer.scheduledTimerWithTimeInterval( 5.0, :target, self, :selector, :periodicUpdate, :userInfo, nil, :repeats, true )
but this now gives me the error:
undefined method `scheduledTimerWithTimeInterval' for NSTimer:Class (NoMethodError)
Do you have a preferred method for doing backgound tasks in MacRuby - perhaps separate threads?
Thanks, Bob Rice
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
The "NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats"syntax is the RubyCocoa syntax, you need to use the selector approach in MacRuby, very much like obj-C. If you are on 0.5 beta or a recent nightly build, you should get a traceback, otherwise, you can still try to catch the exception and print out the error message and backtrace: begin raise "this is a test" rescue Exception => e raise "#{e.message} #{e.backtrace}" end - Matt On Sun, Oct 11, 2009 at 11:45 AM, Robert Rice <rice.audio@pobox.com> wrote:
Thanks John:: I wasn't familiar with this new syntax. I was using the old syntax "NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats" but I see it doesn't work in MacRuby.
MarRuby is giving me error messages without a traceback. Is there a way to enable tracebacks?
Bob Rice
On Oct 11, 2009, at 12:58 PM, John Shea wrote:
Hi Bob, (you are going to kick yourself) you have misplaced the colon between target and self - there is a comma there, and the colon has been placed in front of "target", so the method is not being recognised.
eg: @synchro_timer = NSTimer.scheduledTimerWithTimeInterval(TIME_INTERVAL, target:self, selector:"synchronise_with_server:", userInfo:nil, repeats:true)
as for threads - maybe someone else could chime in with a preference - but I do it the Cocoa way (eg http Connection delegates or timers) - but for data crunching using all cores I will use something like Laurent's barber shop code: http://www.macruby.org/blog/2009/10/07/macruby05b1.html.
J
On Oct 11, 2009, at 6:19 PM, Robert Rice wrote:
Congratulations MacRuby Development Team: My application almost runs now in MacRuby.
Is NSTimer class supported in MacRuby?
I was doing background processing using NSTimer as follows:
@timer = NSTimer.scheduledTimerWithTimeInterval( 5.0, :target, self, :selector, :periodicUpdate, :userInfo, nil, :repeats, true )
but this now gives me the error:
*undefined method `scheduledTimerWithTimeInterval' for NSTimer:Class (NoMethodError)* * * *Do you have a preferred method for doing backgound tasks in MacRuby - perhaps separate threads?
Thanks, Bob Rice
* _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Matt: I am using the most recent build. I get a traceback for compile errors but not for execution errors on the NS run loop. Bob On Oct 11, 2009, at 2:49 PM, Matt Aimonetti wrote:
The "NSTimer. scheduledTimerWithTimeInterval_target_selector_userInfo_repeats "syntax is the RubyCocoa syntax, you need to use the selector approach in MacRuby, very much like obj-C.
If you are on 0.5 beta or a recent nightly build, you should get a traceback, otherwise, you can still try to catch the exception and print out the error message and backtrace:
begin raise "this is a test" rescue Exception => e raise "#{e.message} #{e.backtrace}" end
- Matt
On Sun, Oct 11, 2009 at 11:45 AM, Robert Rice <rice.audio@pobox.com> wrote: Thanks John::
I wasn't familiar with this new syntax. I was using the old syntax "NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats " but I see it doesn't work in MacRuby.
MarRuby is giving me error messages without a traceback. Is there a way to enable tracebacks?
Bob Rice
On Oct 11, 2009, at 12:58 PM, John Shea wrote:
In theory any runtime exception should be caught by the runloop and you should see a line in your Xcode console. As for your timer question, using NSTimer is definitely good in case your callback doesn't do too much. Since this will all be run in the main thread through the run loop, if you see some performance problems it might be better to switch to a Thread instead. Laurent On Oct 11, 2009, at 12:55 PM, Robert Rice wrote:
Hi Matt:
I am using the most recent build.
I get a traceback for compile errors but not for execution errors on the NS run loop.
Bob
On Oct 11, 2009, at 2:49 PM, Matt Aimonetti wrote:
The "NSTimer. scheduledTimerWithTimeInterval_target_selector_userInfo_repeats "syntax is the RubyCocoa syntax, you need to use the selector approach in MacRuby, very much like obj-C.
If you are on 0.5 beta or a recent nightly build, you should get a traceback, otherwise, you can still try to catch the exception and print out the error message and backtrace:
begin raise "this is a test" rescue Exception => e raise "#{e.message} #{e.backtrace}" end
- Matt
On Sun, Oct 11, 2009 at 11:45 AM, Robert Rice <rice.audio@pobox.com> wrote: Thanks John::
I wasn't familiar with this new syntax. I was using the old syntax "NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats " but I see it doesn't work in MacRuby.
MarRuby is giving me error messages without a traceback. Is there a way to enable tracebacks?
Bob Rice
On Oct 11, 2009, at 12:58 PM, John Shea wrote:
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hi Laurent: NSTimer wil work well for my app except I will still need to use a thread to read data from my GPS receiver unless I can find a non- blocking serial I/O package. I see that Apple has developed a "Core Location Framework" for the iPhone but I don't see any documentation to indicate that I could use it in a Cocoa environment. That would be a preferable solution not only for portability but also to solve the problem I have had for years with multiple applications trying to read data from my receiver at the same time. The Core Location Framework should work on OSX if it can find any suitable GPS receiver attached to the local network; then GPS nav apps could get the position info from the framework as on the iPhone. Is there any way to suggest this project to Apple? Bob Rice On Oct 11, 2009, at 3:58 PM, Laurent Sansonetti wrote:
In theory any runtime exception should be caught by the runloop and you should see a line in your Xcode console.
As for your timer question, using NSTimer is definitely good in case your callback doesn't do too much. Since this will all be run in the main thread through the run loop, if you see some performance problems it might be better to switch to a Thread instead.
Laurent
On Oct 11, 2009, at 12:55 PM, Robert Rice wrote:
Hi Matt:
I am using the most recent build.
I get a traceback for compile errors but not for execution errors on the NS run loop.
Bob
On Oct 11, 2009, at 2:49 PM, Matt Aimonetti wrote:
On Oct 11, 2009, at 1:45 PM, Robert Rice wrote:
NSTimer wil work well for my app except I will still need to use a thread to read data from my GPS receiver unless I can find a non- blocking serial I/O package.
[ jkh jumps up and down yelling "GCD! GCD!" until he is dragged away]
The Core Location Framework should work on OSX if it can find any suitable GPS receiver attached to the local network; then GPS nav apps could get the position info from the framework as on the iPhone. Is there any way to suggest this project to Apple?
File an enhancement request radar via http://bugreport.apple.com. Believe it or not, those do get read! - Jordan
Well in the meantime, doesn't a daemon that issues distributed notifications accomplish a similar goal? Hunted and pecked from my iPhone On Oct 11, 2009, at 2:10 PM, "Jordan K. Hubbard" <jkh@apple.com> wrote:
On Oct 11, 2009, at 1:45 PM, Robert Rice wrote:
NSTimer wil work well for my app except I will still need to use a thread to read data from my GPS receiver unless I can find a non- blocking serial I/O package.
[ jkh jumps up and down yelling "GCD! GCD!" until he is dragged away]
The Core Location Framework should work on OSX if it can find any suitable GPS receiver attached to the local network; then GPS nav apps could get the position info from the framework as on the iPhone. Is there any way to suggest this project to Apple?
File an enhancement request radar via http://bugreport.apple.com. Believe it or not, those do get read!
- Jordan
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks: I filed the request. Bob Rice On Oct 11, 2009, at 5:10 PM, Jordan K. Hubbard wrote:
On Oct 11, 2009, at 1:45 PM, Robert Rice wrote:
NSTimer wil work well for my app except I will still need to use a thread to read data from my GPS receiver unless I can find a non- blocking serial I/O package.
[ jkh jumps up and down yelling "GCD! GCD!" until he is dragged away]
The Core Location Framework should work on OSX if it can find any suitable GPS receiver attached to the local network; then GPS nav apps could get the position info from the framework as on the iPhone. Is there any way to suggest this project to Apple?
File an enhancement request radar via http://bugreport.apple.com. Believe it or not, those do get read!
- Jordan
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On Oct 11, 2009, at 9:19 AM, Robert Rice wrote:
Do you have a preferred method for doing backgound tasks in MacRuby - perhaps separate threads?
I would say GCD is probably your best bet for this, since you can simply arrange to have a ruby block execute when your timer fires. Of course, now that I go looking for documentation in the MacRuby source tree which describes how to do timers "the ruby way", I can't find any, but I'm sure it's hiding in there somewhere, right guys? :) - Jordan
participants (6)
-
John Shea
-
Jordan K. Hubbard
-
Laurent Sansonetti
-
Matt Aimonetti
-
Robert Rice
-
s.ross