Creating Objective-C applications with Node.js

Creating Objective-C applications with Node.js

Native-feeling Mac applications can now be built in JavaScript with NodObjC. This means OS X joins Windows 8 and GNOME in the group of desktop environments that can be targeted with the universal runtime. Hello World looks like the following:

var $ = require('NodObjC')



// First you need to "import" the Framework

$.import('Foundation')



// Setup the recommended NSAutoreleasePool instance

var pool = $.NSAutoreleasePool('alloc')('init')



// NSStrings and JavaScript Strings are distinct objects, you must create an

// NSString from a JS String when an Objective-C class method requires one.

var string = $.NSString('stringWithUTF8String', 'Hello Objective-C World!')



// Print out the contents (calling [string description])

console.log(string)

//   → Prints "Hello Objective-C World!"



pool('drain')