[MacRuby-devel] Translating Obj-C to MacRuby
B. Ohr
jazzbox at 7zz.de
Wed Oct 14 02:10:19 PDT 2009
Hi John,
Am 14.10.2009 um 10:34 schrieb John Shea:
> Hi Bernd,
>
> YES and NO in ObjC are translated to true and false in MacRuby.
>
> so you were probably after:
>
> NSNumber.numberWithBool(false)
>
> (I am curious as to how often that is useful actually)
>
> I will leave the table idea for others to comment - I actually think
> in the end there are only a few rules to learn and then you will
> find yourself translating easily (not that those rules should not go
> in a cheat sheet somewhere - that's probably a good idea).
Shure, there are only few rules, but:
1. there are newbies outside (most of the Obj-C programmers)
2. why should I manually correct those Obj-C things like [aObj: foo] a
thousand times when it can easily be done by a regexp? I don't want a
real translator, I am wanting just a simple []-remover!
>
> With:
> NSDictionary.dictionaryWithObjectsAndKeys "a", "b", nil
>
> I assume that in the original ObjC method is actually passing an
> array which (it seems) must be terminated by a nil (in objC).
> I actually ran across this in another context - passing objects in
> this way - again I will leave others to comment on it, perhaps it is
> an issue.
>
> However why can't you use :
>
> dict = {"b"=>"a"}
> => {"b"=>"a"}
>
> #check class of created dictionary
> dict.class
> => NSMutableDictionary
>
> Why use the long winded ObjC form?
Perhaps you misunderstood me. I know this already and I don't want to
use the long form, I just typed that in macirb to use the RESULT (in
this case {"b"=>"a"}). Perhaps this is the way a Obj-C programmer is
trying out MacRuby because of lacking of documentation.
Bernd
More information about the MacRuby-devel
mailing list