Hi, On Oct 14, 2009, at 1:03 AM, B. Ohr wrote:
Hi all!
Using Cocoa in MacRuby is sometimes a hard job, because all documentation, examples and sample code is Obj-C. For example, I found this piece of code '[NSNumber numberWithBool:NO]' and asked myself how to write that in Macruby.
You can simply pass true or false and MacRuby will do the conversion for you.
I opened macirb and typed:
NSNumber.numberWithBool 0 => false
First I had to laugh and then I thought: Hey implementors of macruby, you really did a great job!
And NSNumbers are converted to Ruby types as you just experienced :)
What do you think about a table on http://www.macruby.org/ which lists all such short (and astonishing) examples. Or even better, why not create a command in the services menu which translates a Obj-C sequence (by regexp).
I think a short tutorial/page on the website would be great, indeed. I don't believe it is easily possible to write an Objective-C -> MacRuby convertor that works most/all the time (because of the C nature of ObjC).
BTW, the second example I tried is:
NSDictionary.dictionaryWithObjectsAndKeys "a", "b", nil
but instead of {"b"=>"a"} I got a seg fault! (ticket is filed)
I replied to the ticket, it seems you forgot to do `framework 'Foundation'' first. Laurent