I've been playing around writting software for Apple's
OS X using their
Cocoa object
oriented application frameworks, as well as the various support tools,
systems for software packaging and general development environment.
Here are some of the results so far.
ClearClock
ClearClock is a simple analogue clock that floats above the desktop.
Since the clock window is transparent the user can click through onto
whatever is underneath. The user can also adjust the colour of the
clock and it's level of transparency, so you can even see what's
underneath the clock face itself. There is an optional second 'hand'
which can be set to either tick, sweep smoothly or, as of version 0.80
have a "Swiss" sweep which moves smoothly for the first 59 seconds of
the minute and then ticks as the minute turns.
Download ClearClock (about 83KB).
Exchange rate tool
Yes, I know that the standard calculator program on OS X does exchange
rate conversion, but (a) I really don't like that program and (b) I
was teaching a friend a bit of Objective C programming one evening and
this is sort of came out of that.
My Exchanger program has a simple user interface which,
according to many people who have used it, is more intuitive than
other similar programs. It remembers the last pair of currencies
between runs, hitting return in one field converts the currency you
just typed and there is a facility for inverting the selected
currencies. Furthermore it is capable of updating the exchange rate
data over the net (it uses the interbank rate from the IMF) and unlike the Calculator program
is does not lock up for a whole minute if it can't get through!
Almost all of the user interface operates using Cocoa bindings and it
makes use of the Dictionary Keys value transformer mentioned below.
Last but not least, the source is available so you can learn from it!
Download Exchanger (about 40K) and the Exchanger source (about 160K).
Skype dialer plug-in for Address Book
The Apple Address Book program supports plug-ins to allow you to do
extra things from the context menu for the various fields. I've
written a plug-in that allows the user to click on a phone number
field and have that number be dialed by the excellent Skype voice-over-IP program.
You can download the plug-in (about
10KB) from here as a zip file; unarchive it and place the resulting
bundle into /Library/Address Book Plug-ins either in the root
of your main disk (for access by all users) or in your home directory
(for use just by yourself). Once you restart Address Book you will
find an extra context menu option when you (left) click next to a
phone number giving you the option to "Skype to" the number. You can
also enter people's skype names in an extra phone number field and
start machine to machine calls the same way.
GNU Readline for Python on OS X 10.3
The Python distribution that comes with Mac OS X does not include the
Readline
support, largely because of the contagious nature of the
Gnu Public License
(GPL). The
package here
retrospectively installs the GNU Readline library and the Python
support for it without making any reference to any non-Free Software
code. In order to comply with the GPL I am providing
details of how to get the source
necessary to build this package, along with a discussion as to why
this situation comes about.
Download Python Readline (about 466K).
NOTE: This package has only been tested on OS X 10.3.2 and 10.3.5
(Panther). I have every reason to believe it will work on any Panther
system using Python 2.3 and have good reason to believe it won't work
elsewhere.
Value Transformer for Dictionary Keys
As of release 10.3 (Panther) of OS X Apple added their "bindings"
system to the developer tools. This allows a developer to bind the
values used in various parts of the user interface built with
Interface Builder to values taken from other objects; when the user
changes the items on the user interface the underlying object is
updated and when the program changes the object the user interface is
updated. This is a powerful tool and can speed up development a great
deal. To make the system more powerful Apple added the concept of
Value Transformers; objects which convert values either into another
value or into a value of another class.
My Dictionary Keys
Transformer is a value transformer which returns a sorted array
containing the keys from a dictionary object. This is particularly
useful for transforming values bound to the
contentValues of a NSPopUpButton or similar. If your
program is to perform operations using one of a number possible sets
of data which the user is to select then you can place the data sets
in a dictionary, each with a name, and allow the user to select the
desired data set from a pop-up menu without any extra coding to get
the names.
This code is freely reusable by anyone who thinks it might be of use.
Download the Dictionary
Keys Transformer source code (about 2.5K).
Examining the start-up system
When OS X boots the
System Starter program looks at all the
entries in the
/System/Library/StartupItems and
/Library/StartupItems directories and works out what needs to
be started and in what order they should start. This works by eash
item specifying in a
plist file what services it provides and
upon what services it depends. I've written a little program which
scans these directories and produces a file to be used with
GraphViz
which gives a visual representation of this dependency struture.
I'm making available to source code to
this program. Download it and compile using the command:
gcc -o StartUpOrder -framework Foundation StartUpOrder.m
Alternatively you can download the command
line executable directly (4.5K gzipped TAR file). You'll need a copy of
GraphViz
for which I recommend the excellent Mac OSX Pixglow port. If you
don't want to go to all this trouble and just want to look at the
dependency structure on OSX 10.3 then you can look at a PDF file of the default ourput.
Sources of source
Cocoa is based on the excellent
Objective
C language which, along with the general design of application
architecture, makes it easy to write reusable components. To date
I've not written any but here are some links to other people's bits of
Cocoa source code:
- Blackhole has some
very useful code fragments available for download under a BSD-link
license. Code includes network sockets, light weight inter-thread
communication, database interfaces and calendar widgets, among other
things.
- The Irate
Scotsman seems to direct a great deal of his anger into producing
exceedingly helpful code examples and has a lot of Cocoa development
stuff on his site (among other things).
- M. Uli
Kusterer has plenty of handy code with nifty features, and he even
has a demo program called NiftyFeatures that lets you try some of them
out!
- Finally, there is a ton of good stuff at CocoaDev, which is a Wiki site for
Mac developers.
©Nicko van Someren, 2004