Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TooTallNate
Created July 15, 2011 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TooTallNate/1085022 to your computer and use it in GitHub Desktop.
Save TooTallNate/1085022 to your computer and use it in GitHub Desktop.
Proposed NodObjC Message-Sending API
var $ = require('NodObjC')
// First you need to "load" the Framework
$.import('Foundation')
// Make the 'NSMutableArray' constructor be global
var NSMutableArray = $.NSMutableArray
// Now let's create an NSMutableArray
, array = NSMutableArray('alloc')('init')
array('addObject', someOtherObject);
array('replaceObjectsInRange', $.NSMakeRange(25, 5)
, 'withObjectsFromArray', someOtherArray
, 'range', $.NSMakeRange(0, 5) );
array('objectAtIndex', 0)('description')('UTF8String');
console.log(array);
var $ = require('NodObjC')
// First you need to "load" the Framework
$.import('Foundation')
// Make the 'NSMutableArray' constructor be global
var NSMutableArray = $.NSMutableArray
// Now let's create an NSMutableArray
, array = NSMutableArray('alloc')('init')
// Add some JS objects to the array
array({ 'addObject': 'Hello Objective-C!' });
array({ 'addObject': { an: 'object' } });
array({ 'addObject': NSMutableArray });
array({ 'replaceObjectsInRange': $.NSMakeRange(25, 5)
, 'withObjectsFromArray': someOtherArray
, 'range': $.NSMakeRange(0, 5) });
array({ 'objectAtIndex': 0 })('description')('UTF8String');
// Print out the contents (calling [array describe])
console.log(array);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment