Thursday, July 29, 2004

Cocoa Programming under Mac OS X

The speaker talked about using Perl as a glue language under Mac OS X, rather than programming graphical applications as some people seemed to be expecting. He briefly discussed AppleScript and the Mac::Glue module, but argued that it is better to use the Cocoa APIs directly by using something like CamelBones or PerlObjCBridge (which ships with Mac OS X 10.3.* by default).

He then went on to talk about scripting the Address Book as way of illustrating his points by accessing the Cocoa API using PerlObjCBridge using the Foundation module, which is a low level module which talking to the generated C code rather than the ObjC code itself.

use Foundation;

my $frameworkpayj =

my $framework =
NSBundle->alloc->initWithPath_( $frameworkPath );


There is documentation in the /Developer/Documentation/ directory for the ObjC interface, and there is perldoc for the module (but not for the Foundation class itself).

Looking at the presentation, the ObjC wrappers look to be very low level, suprisingly so... perhaps I should look at CamelBones if I actually want to start writing Mac native applications using Perl as the glue.