NodeJS ⇆ Objective-C bridgeThe
NodObjC exposes the Objective-C runtime to NodeJS in a high-level, easy
to use fashion. It uses the
BridgeSupport files to dynamically generate an
API from an Objective-C "Framework", and uses
node-ffi to dynamically interact
with the Objective-C runtime.
NodObjC is similar in nature to the other popular Objetive-C
npm, of course!
$ npm install NodObjC
This module offers a bi-directional bridge between NodeJS and the Objective-C runtime. What does that mean exactly? Well due to the design of the Objective-C runtime, it is possible to port the entire API to other languages. There are quite a few bridges for Obj-C so one for node was a necessity.
// In NodObjC, you send a message to an object like: obj('func', arg)
In Objective-C, the names of methods are part of the arguments that you pass along:
[array insertObject:obj atIndex:5];
The equivalent of the above message invocation in NodObjC syntax would be:
array('insertObject', obj, 'atIndex', 5)
So the even numbered arguments are the parts of the method name that will be
invoked, and the odd numbered arguments are the Obj-C arguments themselves. In
the above example, the
insertObject:atIndex: function will be invoked.
NodObjC, not only is the Objective-C runtime exposed, but so are the
corresponding C functions that usually go along with these APIs (thanks to
BridgeSupport). So for example, we can make an
NSRect by calling the
NSMakeRect() C function:
$.NSMakeRect(5, 10, 8, 30) // -> NSRect struct
There's literally thousands of other Objective-C resources and tutorials out there.
Support / Getting Involved
If you're looking for support for developing with/for
NodObjC you might want
to check out the #nodobjc channel in the freenode IRC server.
Additional topics of discussion can be found on the Wiki page.