Inline::ObjC

| | Comments (0)
Nuno Cruces provided me the following gem (hacked up by yours truly):
require 'inline'

class Inline::ObjC < Inline::C
  def initialize(mod)
    super(mod)
  end

  def import(header)
    @src << "#import #{header}"
  end
end

class MyClass
  inline(:ObjC) do |builder|
    builder.import "<Foundation/NSString.h>"
    builder.add_compile_flags '-x objective-c', '-framework Foundation'

    builder.c %q{
      void test() {
        printf("%s\n", [@"Hello World!" cString]);
      }
    }
  end
end

MyClass.new.test
I love it... OSX hackers, have at it...

Leave a comment

About this Entry

This page contains a single entry by zenspider published on December 14, 2005 4:16 AM.

Splat is good for you was the previous entry in this blog.

304 Not Modified for Rails is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 4.23-en