NodObjC
=======
### The [Node.js][] ⇆ [Objective-C][ObjCWikipedia] bridge
[![Build Status](https://travis-ci.org/TooTallNate/NodObjC.svg?branch=master)](https://travis-ci.org/TooTallNate/NodObjC)
`NodObjC` exposes the Objective-C runtime to [Node.js][] in a high-level, easy
to use fashion. It uses the `BridgeSupport` files to dynamically generate an
API from an Objective-C "Framework", and uses the node `ffi` module to dynamically interact
with the Objective-C runtime.
Essentially, `NodObjC` is similar in nature to the other popular Objective-C
scripting bridges:
* [JSCocoa][]
* [PyObjC][]
* [MacRuby][]
* [And the others…][others]
So you can write entire Cocoa or iOS GUI applications entirely in Node.js
JavaScript! Applications are interpreted at runtime through the V8 engine,
rather than (pre)compiled to a (binary) machine exectuable. This has the advantage of being
able to tweak code without having to recompile; excellent for rapid prototyping
and development (or for those GUI applications where absolute speed is not a
requirement, i.e. _most_). So what are you waiting for? Get to coding!
Installation
------------
Install using `npm`, of course!
``` bash
$ npm install nodobjc
```
Or add it to the `"dependencies"` section of your _package.json_ file.
Hello World
-----------
``` javascript
var $ = require('nodobjc')
// First you import the "Foundation" framework
$.framework('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 (toString() ends up calling [string description])
console.log(string)
// → Prints "Hello Objective-C World!"
pool('drain')
```
Be sure to check out the [full API docs][docs].
Introduction
------------
This module offers a bi-directional bridge between Node.js and the Objective-C
runtime. What does that mean exactly? Well due to the design of the Objective-C
runtime, it is possible to _port_ the entire API to other languages. There are
quite a few bridges for Obj-C so one for node was a necessity.
So with this module, you get access to _all_ of the Objective-C APIs, but you
invoke them through JavaScript. Obj-C has a concept of "message passing" to
invoke methods on objects. The way that you pass messages around is probably a
little bit different than the kind of JavaScript you're used to:
``` javascript
// In JavaScript, you invoke a function on an object like:
obj.func(arg)
```
Compared to:
``` javascript
// In NodObjC, you send a message to an object like:
obj('func', arg)
```
In Objective-C, the names of methods are part of the arguments that you pass
along:
``` objective-c
[array insertObject: obj
atIndex: 5]
```
The equivalent of the above message invocation in NodObjC syntax would be:
``` javascript
array('insertObject', obj,
'atIndex', 5)
```
So the even numbered arguments are the parts of the method name that will be
invoked, and the odd numbered arguments are the Obj-C arguments themselves. In
the above example, the `insertObject:atIndex:` function will be invoked.
In `NodObjC`, not only is the Objective-C runtime exposed, but so are the
corresponding C functions that usually go along with these APIs (thanks to
BridgeSupport). So for example, we can make an `NSRect` by calling the
`NSMakeRect()` C function:
``` javascript
$.NSMakeRect(5, 10, 8, 30)
// -> NSRect struct
```
There's a plethora of other Objective-C resources and tutorials out there.
You should definitely have Apple's official [Mac][MacDev] or [iOS][iOSDev] API
docs handy at all times.
Support / Getting Involved
---------------------------
If you're looking for support for developing with/for `NodObjC` you might want
to join the [mailing list][group], and check out the [#nodobjc][IRC] channel
in the Freenode IRC server.
Additional topics of discussion can be found on the [Wiki][] page.
[docs]: http://tootallnate.github.io/NodObjC
[group]: https://groups.google.com/d/forum/nodobjc
[Node.js]: http://nodejs.org
[JSCocoa]: http://inexdo.com/JSCocoa
[PyObjC]: http://pyobjc.sourceforge.net
[MacRuby]: http://macruby.org
[IRC]: http://webchat.freenode.net/?channels=nodobjc
[Wiki]: https://github.com/TooTallNate/NodObjC/wiki
[MacDev]: http://developer.apple.com/library/mac/navigation/
[iOSDev]: http://developer.apple.com/library/ios/navigation/
[ObjCWikipedia]: http://en.wikipedia.org/wiki/Objective-C
[others]: http://cocoadev.com/CocoaBridges
没有合适的资源?快使用搜索试试~ 我知道了~
The Node.js ⇆ Objective-C bridge.zip
共103个文件
js:73个
gitignore:3个
plist:3个
需积分: 5 0 下载量 96 浏览量
2024-01-05
14:46:39
上传
评论
收藏 554KB ZIP 举报
温馨提示
The Node.js ⇆ Objective-C bridge
资源推荐
资源详情
资源评论
收起资源包目录
The Node.js ⇆ Objective-C bridge.zip (103个子文件)
AUTHORS 79B
styles.css 1KB
ir_black.css 55B
Current 1B
.gitignore 70B
.gitignore 57B
.gitignore 7B
framework.gyp 773B
test.h 163B
test.h 163B
NodeCocoaHelloWorld.icns 398KB
template.jade 2KB
bg.jpg 23KB
jquery-1.7.1.js 242KB
core.js 15KB
oldimport.js 11KB
import.js 11KB
id.js 9KB
index.js 9KB
types.js 8KB
class.js 7KB
app.js 6KB
method.js 5KB
EventLoop.js 4KB
eventLoop.js 3KB
createInstance.js 3KB
testapp.js 2KB
exception.js 2KB
memtest.js 2KB
uv.js 2KB
introspection.js 2KB
ivar.js 2KB
exception.js 2KB
compile.js 2KB
extend.js 1KB
cast-bool.js 1KB
abstract-class.js 1KB
instanceof-class-id.js 1KB
core.deadcode.js 1KB
struct-pass.js 1KB
nstimer-uv.js 1KB
largeimportold.js 1KB
largeimport.js 1KB
struct.js 1KB
types.js 1014B
variadicfuncs.js 900B
nsapplescript.js 781B
voidconstreturn.js 738B
nstimer.js 725B
getClassList.js 725B
inherits.js 696B
array-references.js 691B
NSLog.js 686B
nserror.js 677B
block.js 615B
super.js 603B
cgevent.js 578B
function_pointer.js 578B
swizzle-dealloc.js 570B
methods.js 555B
struct-test.js 529B
gcissue2.js 514B
ancestors.js 495B
gcissue1.js 472B
informal_protocol.js 469B
global-test.js 426B
exception-bad-selector.js 424B
test.js 415B
cast-buffer.js 405B
cast-regexp.js 384B
sb.js 374B
nsstring.js 362B
resolve.js 345B
import.js 330B
cast-date.js 303B
resolveFrameworkConstants.js 288B
cast-string.js 287B
cast-number.js 282B
nsstring-length.js 260B
repl.js 255B
array.js 253B
NSMakeRect.js 242B
script.js 232B
respondsToSelector.js 190B
NSMakePoint.js 169B
global.js 99B
.jshintrc 52B
package.json 894B
LICENSE 1KB
test.m 143B
Makefile 815B
README.md 5KB
History.md 2KB
NodeCocoaHelloWorld 80B
Info.plist 857B
Info.plist 631B
Info.plist 631B
caution.png 616B
Resources 26B
run.sh 293B
共 103 条
- 1
- 2
资源评论
Lei宝啊
- 粉丝: 1997
- 资源: 1330
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 以简单、易用、高性能为目标、开源的时序数据库,支持Linux及Windows, Time Series Database.zip
- python-leetcode面试题解之第198题打家劫舍-题解.zip
- python-leetcode面试题解之第191题位1的个数-题解.zip
- python-leetcode面试题解之第186题反转字符串中的单词II-题解.zip
- 一个基于python的web后端高性能开发框架,下载可用
- python-leetcode面试题解之第179题最大数-题解.zip
- python-leetcode面试题解之第170题两数之和III数据结构设计-题解.zip
- python-leetcode面试题解之第168题Excel表列名称-题解.zip
- python-leetcode面试题解之第167题两数之和II输入有序数组-题解.zip
- python-leetcode面试题解之第166题分数到小数-题解.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功