You mean Ruby calling Objective-C?
Once the MacRuby runtime is initialized, you can access all your Objective-C
objects from Ruby. For example, if you have an Objective-C class named Foo, you
can do `Foo.new', etc.
Another possibility is to pass your Objective-C objects to a Ruby method by
using -[NSObject performRubySelector:].
ruby:
class Foo
def test(o)
o.something
end
end
objc:
MyObject *o = [MyObject new]; // where o responds to -something
MacRuby *runtime = [MacRuby sharedRuntime];
id foo_obj = [runtime evaluateString:@"new Foo"];
[foo_obj performRubySelector:@selector(test:) withArguments: o, NULL];
Check out the whole API here:
http://www.macruby.org/trac/browser/MacRuby/trunk/include/ruby/objc.h
Laurent
On Apr 28, 2010, at 2:17 PM, Alexander von Below wrote:
> Thanks a lot!
>
> I have looked at the EmbeddedRuby app, but I did not see the way "back".
> Could you point me in the right direction?
>
> Alex
> Am 28.04.2010 um 22:55 schrieb Laurent Sansonetti:
>
>> Hi Alexander,
>>
>> On Apr 28, 2010, at 1:49 PM, Alexander von Below wrote:
>>
>>> Hello,
>>>
>>> I have a conceptual question:
>>>
>>> Is it possible for an embedded ruby script running in MacRuby to call back
>>> into my Cocoa Application easily? Or would the only way be to create
>>> distributed Objects or similar IPC mechanisms?
>>
>> It is possible to run the MacRuby runtime inside a pure Objective-C-based
>> Cocoa app, which allows Objective-C to talk to Ruby objects (and vice-versa)
>> inside the same process. Check out the MacRuby.h header file (an Objective-C
>> API to talk to the runtime) inside the framework, or the EmbeddedMacRuby
>> sample app.
>>
>> Laurent
>> _______________________________________________
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel