JSCocoa, a bridge from Javascript to Cocoa

Written by Patrick Geiller — parmanoir@gmail.comGoogle Home — Wanna contribute ? Send me a mail !

QuickStart

Adding JSCocoa to your project

As JSCocoa is not a framework (yet?),

Starting JSCocoa

Starting JSCocoa depends on the lifetime you want for your JS objects.

Garbage Collection

JSCocoa retains objects it uses. To have an object destroyed, delete any reference to it.
	// Standard alloc
	var myObject = MyObjectClass.alloc.init
	// Use object
	...
	// Release
	myObject.release
	// Delete JS reference — object is now collectable
	myObject = null

	// Manually collect - object will be destroyed
	JSCocoaController.garbageCollect
You can use instance instead of alloc/init.
	var object = MyObjectClass.instance
	// Use object
	...
	// Delete JS reference — object is now collectable
	object = null

	// Manually collect - object will be destroyed
	JSCocoaController.garbageCollect

Forgetting to set object = null will cause the object to live forever.

Call JSCocoaController.logInstanceStats to check on your objects' lifetime.