From: Dave Baldwin Date: 2005-10-06T16:48:55+09:00 Subject: Re: RybyCocoa (was The definitive GUI for Ruby) On 5 Oct 2005, at 21:17, Jim Freeze wrote: > On 10/5/05, Rich Morin wrote: > >> You may be interested to know about >> >> RubyCocoa - A Ruby/Objective-C Bridge for Mac OS X with Cocoa >> http://rubycocoa.sourceforge.net/doc >> >> * Objective-C has its own naming conventions and method >> invocation >> syntax, which are quite different from those used by Ruby, >> Python, >> etc. In CamelBones, this means that the programmer has to >> look up >> methods by "translated" names, etc. >> > > From my limited experience, there is a straightforward pattern to > follow to convert from OC to Ruby. For example, from the tutorial: > > [oPanel runModalForDirectory:self file:nil types nil] > > becomes > > oPanel.runModalForDirectory_file_types(self, nil, nil) Or alternatively: oPanel.runModalForDirectory(self, :file, nil :types, nil] which I think is often clearer and preserves the parameter type (recorded as a symbol) by the actual parameter. My limited experience has been that RubyCocoa is very easy to use and there isn't much to learn to map between the ruby and objective c domains. Getting to grips with Cocoa is much harder but at least with RubyCocoa all the memory management headaches go away. Dave. > > > "The other technique can be used to make a little more sense of method > names that are extremely long. Using this technique, the method name > consists of everything in the Objective-C method's name up to the > first detached parameter name. The rest of the parameter names are > moved into the argument list. Thus, every argument after the first is > prefaced with another argument that is a Ruby symbol with the same > name as the parameter it represents. It sounds confusing, I know, but > the example below shows you how easy it is once you get used to the > syntax." > > And, when standard calls return an NSArray or NSString, just use > #to_a and #to_s to convert them to ruby. > > -- > Jim Freeze > >