And by trying a bit I see blocks are not supported,am I right?_______________________________________________2010/5/18 Laurent Sansonetti <lsansonetti@apple.com>
Indeed, methods with normal arities (0..n arguments) conform to the Objective-C ABI, so using the bracket syntax just works. But for Ruby methods using complex arities (like splat or optional arguments), you will likely get a crash. This is why the -performRubySelector: method was introduced. It is better to always use that method, because it always works (in theory).LaurentOn May 18, 2010, at 3:05 PM, Louis-Philippe wrote:great!I can even seem to send messages directly to my MacRuby classes and instances...like:id obj = [Foo new:@"objc"];and_______________________________________________[obj hello];but in the second case I get a compiler warning: "No -hello method found"??2010/5/18 Laurent Sansonetti <lsansonetti@apple.com>Hi Louis-Philippe,
Assuming MacRuby code defines:
class Foo
def initialize(message)
@message
end
def hello
puts "hello #{message}"
end
end
You should be able to retrieve a reference to Foo using:
Class Foo = [[MacRuby sharedRuntime] evaluateString:@"Foo"];
Or, more simply:
Class foo = NSClassFromString(@"Foo");
You might want to use the first way in case the class has a complex path (if it's defined inside modules, like "Foo::Bar").
Later, you can send messages to it.
id obj = [Foo performRubySelector:@selector(new:) withArguments: @"objc", nil];
[obj performRubySelector:@selector(hello)];
Laurent
> _______________________________________________
On May 18, 2010, at 2:31 PM, Louis-Philippe wrote:
> Hi,
> I don't know if this is the good list to ask this question as it is my first...
> So,
>
> I saw how I can have a MacRuby cocoa app, importing objective-c classes.
> I can't find info on how to do the opposite... having an Objective-C cocoa app, importing and using MacRuby Classes...
>
> All I managed to do is to "evaluateFileAtPath:" and "evaluateString:"
>
> Thanks!
>
> L-P
> 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
_______________________________________________
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