moccacino
moccacino copied to clipboard
Crazy CoffeeScript to Objective-C/Cocoa translator
PLEASE NOTE, THIS IS NOT YET WORKING!!!
I have this crazy idea of translating CoffeeScript to Objective-C for use in Apple Cocoa projects. This is just a little playground and I'm not quite sure if those two worlds can ever work together in a nice way, but at least I will give it a try.
HOW TO IMPLEMENT
My idea is that you set up your projects in Xcode as you are used to. For discrete classes like custom views and controllers you then might want to use a CoffeeScript file which will then automatically become translated to a header and an implementation file. (This could use 'Pre-actions' like I do in my XObjC project https://github.com/holtwick/xobjc)
The great strength of CoffeeScript is that you do not have to care a lot about the high level objects like dictionaries and lists. These should then be mapped to NSObject based values. Also the better string handling could save a lot of time and headaches. Everything should become an object and they should know how to interact with each other.
For the IBActions and IBOutlets we might need some coding conventions. Also for calling and defining Objective C methods. As much as possible it should be a typeless, so arguments in newly defined methods would most probably become 'id' objects.
The profit of all this could be writing native Cocoa apps with much less code!
SAMPLE
class MyViewController extends UIViewController
IBOUTLET =
myView: UIView
viewDidLoad: ->
@title = 'Test #{ somevariable }'
@view.addSubview @myView
@addSubview @myView
@myView.setFrame 1,2,3,4
viewDidAppear_animated: (view, animated) ->
NSLog 'Great!'
IBACTION_doSomething: (sender) ->
@myView.hidden = 1
REFERENCE
All work is based on CoffeeScript: http://coffeescript.org/
The original repo forked from on 2011--8-11: git://github.com/jashkenas/coffee-script.git