Created
December 17, 2011 23:47
-
-
Save Watson1978/1491832 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 ruby; | |
id foo; | |
ruby = [[MacRuby sharedRuntime] evaluateFileAtPath:@"test.rb"]; | |
foo = [ruby performRubySelector:@selector(main:) 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
def main(str) | |
Foo.new(str) | |
end | |
class Foo | |
def initialize(str = "") | |
@str = str.to_s | |
end | |
def hello | |
"Hello, MacRuby #{@str}" | |
end | |
end |
Author
Watson1978
commented
Dec 17, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment