My favorites | Sign in
Project Logo
                
Show all Featured downloads:
JSCocoa 1.0.zip
Show all Featured wiki pages:
HowJSCocoaWorks iPhone
People details
Project owners:
  parmanoir



Source is now on Github http://github.com/parmanoir/jscocoa/tree



Talk about JSCocoa on the JSCocoa Google Group !

Check out QuickStart.

Write Cocoa apps in Javascript ! JSCocoa allows calling Cocoa and C functions through JavascriptCore (Webkit's Javascript engine), using BridgeSupport and libffi to call C functions and allocate C structs. Calling Objective C is done via ObjCRuntime.

JSCocoa uses parts of PyObjC.

Syntax

Dot !

var appName = NSWorkspace.sharedWorkspace.activeApplication.NSApplicationName

Instance

NSButton.alloc.initWithFrame(NSMakeRect(0, 0, 100, 40))  // Need release
NSButton.instance({ withFrame:NSMakeRect(0, 0, 100, 40) }) // Handled by JS GC

Get/Set

var title = window.title 
window.title = 'Hello !'

Call, Split call

obj.call({ withParam1:'Hello', andParam2:'World' }) 
obj['callWithParam1:andParam2:']('Hello', 'World') 
obj.callWithParam1_andParam2('Hello', 'World' )

Derivation : Child Cocoa classes written in Javascript

defineClass('MyButton < NSButton', 
{
	 myOutlet : 'IBOutlet'
	,myAction : ['IBAction', 
		function (sender)
		{
			...
		}]
})

Interface Builder

JSCocoa works with NIBs, but you'll need to manually add IBOutlets and IBActions while creating your interface. If you've ever wondered why there are + and - buttons in the Identity Inspector, wonder no more ! :)









Hosted by Google Code