Skip to content
This repository
Newer
Older
100644 146 lines (105 sloc) 4.549 kb
fed9744c »
2011-07-10 Add README
1 NodObjC
2 =======
c5d6d88f »
2011-09-14 Add link to Objective-C Wikipedia article.
3 ### The [NodeJS][] ⇆ [Objective-C][ObjCWikipedia] bridge
fed9744c »
2011-07-10 Add README
4
5
6 `NodObjC` exposes the Objective-C runtime to [NodeJS][] in a high-level, easy
7 to use fashion. It uses the `BridgeSupport` files to dynamically generate an
713ad89f »
2011-08-25 README++
8 API from an Objective-C "Framework", and uses `node-ffi` to dynamically interact
9 with the Objective-C runtime.
fed9744c »
2011-07-10 Add README
10
11 Essentially, `NodObjC` is similar in nature to the other popular Objetive-C
12 scripting bridges:
13
0c61ba9d »
2011-08-04 Add links for the other bridges
14 * [JSCocoa][]
15 * [PyObjC][]
97a896c0 »
2012-05-17 README: swap RubyCocoa with MacRuby
16 * [MacRuby][]
530650b6 »
2012-01-27 README++
17 * [And the others…][others]
fed9744c »
2011-07-10 Add README
18
36aaaebc »
2011-10-10 Remove not ready note from README. Add section explaining NodObjC app…
19 So you can write entire Cocoa or iOS GUI applications entirely in NodeJS
20 JavaScript! Applications are interpreted at runtime through the V8 engine,
21 rather than compiled to a machine exectuable. This has the advantage of being
22 able to tweak code without having to recompile; excellent for rapid prototyping
23 and development, or for those GUI applications where absolute speed is not a
24 requirement (i.e. _most_). So what are you waiting for? Get to coding!
164ab52e »
2011-07-15 Add under development notice
25
26
eee24d38 »
2011-09-18 Add 'Installation' section to the README.
27 Installation
28 ------------
29
30 Install using `npm`, of course!
31
0af28166 »
2011-10-07 use bash for syntax highlighting.
32 ``` bash
eee24d38 »
2011-09-18 Add 'Installation' section to the README.
33 $ npm install NodObjC
34 ```
35
616d816b »
2012-07-21 README++
36 Or add it to the `"dependencies"` section of your _package.json_ file.
37
eee24d38 »
2011-09-18 Add 'Installation' section to the README.
38
bdd26bdc »
2011-08-16 README++
39 Hello World
40 -----------
fed9744c »
2011-07-10 Add README
41
42 ``` javascript
8a0acc59 »
2011-08-13 redo README example to be just a Hello World
43 var $ = require('NodObjC')
fed9744c »
2011-07-10 Add README
44
616d816b »
2012-07-21 README++
45 // First you import the "Foundation" framework
46 $.framework('Foundation')
fed9744c »
2011-07-10 Add README
47
9573bbef »
2011-07-16 README update
48 // Setup the recommended NSAutoreleasePool instance
8a0acc59 »
2011-08-13 redo README example to be just a Hello World
49 var pool = $.NSAutoreleasePool('alloc')('init')
fed9744c »
2011-07-10 Add README
50
8a0acc59 »
2011-08-13 redo README example to be just a Hello World
51 // NSStrings and JavaScript Strings are distinct objects, you must create an
52 // NSString from a JS String when an Objective-C class method requires one.
53 var string = $.NSString('stringWithUTF8String', 'Hello Objective-C World!')
fed9744c »
2011-07-10 Add README
54
616d816b »
2012-07-21 README++
55 // Print out the contents (toString() ends up calling [string description])
6d929340 »
2011-09-10 %s not needed since id wraps now have a custom inspect() function.
56 console.log(string)
bdd26bdc »
2011-08-16 README++
57 // → Prints "Hello Objective-C World!"
fed9744c »
2011-07-10 Add README
58
8a0acc59 »
2011-08-13 redo README example to be just a Hello World
59 pool('drain')
fed9744c »
2011-07-10 Add README
60 ```
61
616d816b »
2012-07-21 README++
62 Be sure to check out the [full API docs][docs].
63
bdd26bdc »
2011-08-16 README++
64
65 Introduction
66 ------------
67
68 This module offers a bi-directional bridge between NodeJS and the Objective-C
69 runtime. What does that mean exactly? Well due to the design of the Objective-C
70 runtime, it is possible to _port_ the entire API to other languages. There are
71 quite a few bridges for Obj-C so one for node was a necessity.
72
73 So with this module, you get access to _all_ of the Objective-C APIs, but you
74 invoke them through JavaScript. Obj-C has a concept of "message passing" to
75 invoke methods on objects. The way that you pass messages around is probably a
76 little bit different than the kind of JavaScript you're used to:
77
78 ``` javascript
79 // In JavaScript, you invoke a function on an object like:
80 obj.func(arg)
81 ```
82
83 Compared to:
84
85 ``` javascript
86 // In NodObjC, you send a message to an object like:
87 obj('func', arg)
88 ```
89
90 In Objective-C, the names of methods are part of the arguments that you pass
8bad4fea »
2011-08-19 Add Objective-C example for comparison.
91 along:
92
93 ``` objective-c
31327b1a »
2012-05-20 README: line up the message sending example
94 [array insertObject: obj
95 atIndex: 5]
8bad4fea »
2011-08-19 Add Objective-C example for comparison.
96 ```
97
98 The equivalent of the above message invocation in NodObjC syntax would be:
bdd26bdc »
2011-08-16 README++
99
100 ``` javascript
31327b1a »
2012-05-20 README: line up the message sending example
101 array('insertObject', obj,
102 'atIndex', 5)
bdd26bdc »
2011-08-16 README++
103 ```
104
105 So the even numbered arguments are the parts of the method name that will be
106 invoked, and the odd numbered arguments are the Obj-C arguments themselves. In
107 the above example, the `insertObject:atIndex:` function will be invoked.
108
109 In `NodObjC`, not only is the Objective-C runtime exposed, but so are the
110 corresponding C functions that usually go along with these APIs (thanks to
111 BridgeSupport). So for example, we can make an `NSRect` by calling the
112 `NSMakeRect()` C function:
113
114 ``` javascript
115 $.NSMakeRect(5, 10, 8, 30)
116 // -> NSRect struct
117 ```
118
e58a52cf »
2012-04-23 README++
119 There's a plethora of other Objective-C resources and tutorials out there.
bdd26bdc »
2011-08-16 README++
120
dd68a960 »
2011-08-25 fix
121 You should definitely have Apple's official [Mac][MacDev] or [iOS][iOSDev] API
9dbb9a58 »
2011-08-25 README++
122 docs handy at all times.
bdd26bdc »
2011-08-16 README++
123
c92dd608 »
2011-09-04 Fix README typo.
124 Support / Getting Involved
6d343bc0 »
2011-08-24 Add IRC room and Wiki page links.
125 ---------------------------
8c447d84 »
2011-08-17 Add #nodobjc node to README.
126
127 If you're looking for support for developing with/for `NodObjC` you might want
8610134b »
2012-07-23 README++
128 to join the [mailing list][group], and check out the [#nodobjc][IRC] channel
129 in the Freenode IRC server.
6d343bc0 »
2011-08-24 Add IRC room and Wiki page links.
130
131 Additional topics of discussion can be found on the [Wiki][] page.
8c447d84 »
2011-08-17 Add #nodobjc node to README.
132
133
8610134b »
2012-07-23 README++
134 [docs]: http://tootallnate.github.com/NodObjC
135 [group]: https://groups.google.com/d/forum/nodobjc
fed9744c »
2011-07-10 Add README
136 [NodeJS]: http://nodejs.org
0c61ba9d »
2011-08-04 Add links for the other bridges
137 [JSCocoa]: http://inexdo.com/JSCocoa
138 [PyObjC]: http://pyobjc.sourceforge.net
97a896c0 »
2012-05-17 README: swap RubyCocoa with MacRuby
139 [MacRuby]: http://macruby.org
6d343bc0 »
2011-08-24 Add IRC room and Wiki page links.
140 [IRC]: http://webchat.freenode.net/?channels=nodobjc
141 [Wiki]: https://github.com/TooTallNate/NodObjC/wiki
9dbb9a58 »
2011-08-25 README++
142 [MacDev]: http://developer.apple.com/library/mac/navigation/
143 [iOSDev]: http://developer.apple.com/library/ios/navigation/
c5d6d88f »
2011-09-14 Add link to Objective-C Wikipedia article.
144 [ObjCWikipedia]: http://en.wikipedia.org/wiki/Objective-C
28f6ea69 »
2011-10-09 Add link to a big list of other Cocoa bridges.
145 [others]: http://www.cocoadev.com/index.pl?CocoaBridges
Something went wrong with that request. Please try again.