Skip to content

Instantly share code, notes, and snippets.

@mralexgray
Forked from thomaswrenn/index.js
Last active December 15, 2015 04:49
Show Gist options
  • Save mralexgray/f9bb3b13537f834289b2 to your computer and use it in GitHub Desktop.
Save mralexgray/f9bb3b13537f834289b2 to your computer and use it in GitHub Desktop.
NodObjC works with ObjC Blocks
$ = require 'nodobjc'
$.import 'Foundation'
$.NSAutoreleasePool 'new'
randChar = -> $(String.fromCharCode Math.round(Math.random() * 26) + 'a'.charCodeAt 0 )
array = $.NSMutableArray 'new'
array 'addObject', randChar() for i in [1..10]
signature = ['v',['?', '@','I','^B']]
blockDecl = ((self, obj, index, bool) -> console.log "#{obj} == #{index}")
array 'enumerateObjectsUsingBlock' : $ blockDecl, signature
console.log array 'componentsJoinedByString' : $ ','
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment