-
-
Save kyab/1492002 to your computer and use it in GitHub Desktop.
Objective-C + MacRuby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
#import <MacRuby/MacRuby.h> | |
int main(void) | |
{ | |
id fooClass; | |
id foo; | |
[[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"]; | |
fooClass = [[MacRuby sharedRuntime] evaluateString:@"Foo"]; | |
foo = [fooClass performRubySelector:@selector(new) withArguments:@"from Objc", NULL]; | |
NSLog(@"%@", foo); | |
NSLog(@"%@", [foo hello]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def initialize(str = "") | |
@str = str.to_s | |
end | |
def hello | |
"Hello, MacRuby #{@str}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ gcc objc-macruby.m -framework Foundation -framework MacRuby -fobjc-gc
$ ./a.out
2011-12-18 18:04:10.356 a.out[27436:60b] #Foo:0x400cb8e40
2011-12-18 18:04:10.365 a.out[27436:60b] Hello, MacRuby from Objc