Re: [MacRuby-devel] I tried converting a working script rubycocoa script to macruby and it failed on this line...
Thanks Vincent, You're suggestion fixed the script. The top line is the original rubycocoa line and the line below the macruby equivalent. It would be nice to add such an example to the tutorial at http://www.macruby.org/trac/wiki/MacRubyTutorial (please kind maintainer--if you are listening). It is not obvious that macruby would require quotes and a trailing colon when passing the name of a selector/method. I don't think there are any examples that cover this rule currently. Thanks, Tim center.addObserver_selector_name_object(self, :next_number, "next number", "com.imasender") #rubycocoa center.addObserver self, selector: "next_number:", name: "next number", object: "com.imasender" #macruby On Fri, Dec 12, 2008 at 7:00 AM, <macruby-devel-request@lists.macosforge.org
wrote:
Send MacRuby-devel mailing list submissions to macruby-devel@lists.macosforge.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel or, via email, send a message with subject or body 'help' to macruby-devel-request@lists.macosforge.org
You can reach the person managing the list at macruby-devel-owner@lists.macosforge.org
When replying, please edit your Subject line so it is more specific than "Re: Contents of MacRuby-devel digest..."
Today's Topics:
1. I tried converting a working script rubycocoa script to macruby and it failed on this line... (Tim Rand) 2. Re: I tried converting a working script rubycocoa script to macruby and it failed on this line... (Vincent Isambart)
----------------------------------------------------------------------
Message: 1 Date: Thu, 11 Dec 2008 21:55:04 -0800 From: "Tim Rand" <timrandg@gmail.com> Subject: [MacRuby-devel] I tried converting a working script rubycocoa script to macruby and it failed on this line... To: macruby-devel@lists.macosforge.org Message-ID: <ea8cb0bb0812112155q3c4873f1q3627a8227477eec9@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1"
NSDistributedNotificationCenter.defaultCenter.addObserver_selector_name_object(self, :next_number, "next number", "com.imasender") #Working RubyCocoa line
NSDistributedNotificationCenter.defaultCenter.addObserver self, selector: :next_number, name: "next number", object: "com.imasender" #But gives the error below when converted to MacRuby grammer and run with macruby.
2008-12-11 21:45:43.448 macruby[66187:10b] *** -[Receiver next_number]: unrecognized selector sent to instance 0x1319720 receiver.rb:29:in `run': NSInvalidArgumentException: *** -[Receiver next_number]: unrecognized selector sent to instance 0x1319720 (RuntimeError) from receiver.rb:29:in `<main>'
It's driving me crazy. If the statement is a correct translation from RubyCocoa to MacRuby syntax why am I getting a "unrecognized selector sent to..." error?
participants (1)
-
Tim Rand