From: FUJIMOTO H. <hi...@im...> - 2003-10-13 23:23:52
|
At Mon, 13 Oct 2003 10:13:09 -0600, Rod Schmidt wrote: > Unless I'm missing something (you may need to point me to something more > specific), I think you misunderstood me. I'm not trying to call Cocoa > classes from Ruby but Ruby classes from an Objective-C Cocoa app. I'm very sorry. You was not missing anything, but I had jumped to a misleading conclusion about your message. Now, I have understood your question, maybe. > Is there another way to do this besides using Ruby's C API.? How > could I do it using the RubyCocoa framework? I guess that the following show an answer of your question: /* cc -I/usr/lib/ruby/1.6/powerpc-darwin6.0 -framework Cocoa -framework RubyCocoa test.m */ #import <Cocoa/Cocoa.h> #import <RubyCocoa/RubyCocoa.h> int main() { id pool; id obj; RBRubyCocoaInit(); /* initialize Ruby and RubyCocoa */ pool = [[NSAutoreleasePool alloc] init]; obj = [RBObject RBObjectWithRubyScriptCString: "'hello world'" ]; /* eval string */ NSLog(@"%@", obj); obj = [[RBObject alloc] initWithRubyObject: rb_cTime]; NSLog(@"%@", obj); obj = [obj now]; /* obj is a RBObject with wrapping a result of obj.now */ NSLog(@"%@", obj); [pool release]; return 0; } -- Hisa |