Skip to content

Instantly share code, notes, and snippets.

@Watson1978
Forked from kyab/objc-macruby.m
Created December 18, 2011 11:24
Show Gist options
  • Save Watson1978/1493069 to your computer and use it in GitHub Desktop.
Save Watson1978/1493069 to your computer and use it in GitHub Desktop.
Objective-C + MacRuby
#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]);
}
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