Oct 24 2006

RubyConf: Leveraging Mac OS X From Ruby

Laurent Sansonetti of Apple gave an awesome presentation on RubyOSA. RubyOSA is a Ruby/AppleEvent bridge that allows Ruby programs to interact and manipulate Apple applications in the same fashion that AppleScript can. Here is a code sample from the RubyOSA site:

require ‘rbosa’
app = OSA.app_with_name(‘iTunes’)
track = app.current_track
p track # -> #<OSA::Itunes::File_track:0x1495e20>
p track.name # -> “Over The Rainbow”
p track.artist # -> “Keith Jarrett”
p track.duration # -> 362
p track.date_added.to_s # -> “2006-06-30”
p track.enabled? # -> true

According to Laurent, Ruby has been shipped with OS X since 10.2, ‘Jaguar’ which buncled Ruby 1.6.7. Apple packages Ruby as a framework which is easier for Mac development and allows versioning. In addition to Ruby, OS X includes RubyGems and gems like rake, rails and friends (mongrel, capistrano), libxml2, and sqlite3. Laurent mentioned that he is open to suggestions for adding including additional gems into OS X.
Continue reading

May 17 2006

Design This Container

I attended the Creating Professional Swing UIs Using NetBeans GUI Builder (Formerly Code-Named “Matisse”). I been meaning to get started with the NetBeans GUI Builder to become a more productive UI developer. An important point for me is that Matisse supports custom components. This is important for me because at my company we have developed a lot of custom components. The Matisse GUI Builder is a WYSIWYG visual builder with a drag and drop feel which can be used to design an UI as oppose to developing one. Of course UI builders are great to quickly prototype an application.

The NetBeans UI Builder reminds me a of XCode’s Interface Builder. An IDE has context help, and UI Builder, like Interface Builder, have alignment help. With both these tools, UI design becomes an art rather than a science. At the end of the session one of the speakers simple summed up the session as, “Hand coding bad, Matisse good.”

Here is a good design practice when using the NetBeans UI Builder: Design every container as resizable.

Technorati Tags: , , , ,

Apr 23 2006

Hello World Cocoa

Want to be a Mac Developer? Well, OS X and Xcode makes it easy to start hacking your ideas into Apple applications. I started to ‘write’ a Hello World program using Xcode. In less than five minutes and no coding at all I was able to create what I had in mind:

#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
   NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

   // insert code here...
   NSLog(@"Hello, World!");
   [pool release];
   return 0;

The above code was auto-generated for me by Xcode. Now only if Xcode could auto-generate the code for a new killer app that I been dreaming of.

I also want to note that the above code is a command line, Foundation Tool, application.

The @”Hello, World!” piece of code is a NSString literal. You night also have noticed that there are a lot of types that start with NS. The NS prefix stands for Next Step which is where Cocoa first started out.

Technorati Tags: , , ,