Created
July 15, 2011 16:30
-
-
Save TooTallNate/1085022 to your computer and use it in GitHub Desktop.
Proposed NodObjC Message-Sending API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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