| Article: |
Read iCal Data with Ruby | |
| Subject: | Ruby with Objective-C? | |
| Date: | 2003-10-04 16:56:53 | |
| From: | anonymous2 | |
|
Hi,
|
||
Showing messages 1 through 2 of 2.
-
Ruby with Objective-C?
2003-10-05 12:30:02 rschmidt [Reply | View]
For more information look at www.rubycentral.com. There you will find a free online version of Programming Ruby: The Pragmatic Programmer's Guide.
Ruby includes a C API to extend it, so you could certainly use that to invoke Ruby classes from Objective-C.
There might be another way using the RubyCocoa framework and for that I'm trying to get some answers from the RubyCocoa mailing list.




/* 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);
/* Create a Ruby Time instance */
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;
}