Copyright ©1997 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H.  All Rights Reserved. Revision 1.02 - October 28, 1997.

Extending Joy by Objective-C classes

This mini-example shows how to extend the functionality of the Joy interpreter with compiled Objective-C classes.

Start the Joy interpreter (e.g. inside InterfaceBuilder if you have the Joy palette installed - see the Joy tutorial for details) and change to this directory by typing at the prompt:

          joy> cd $env(NEXT_ROOT)/LocalLibrary/Joy/Examples/ObjC-Extensions

The file Thermometer.m contains the Objective-C source of a simple class converting temperatures from Celsius to Fahrenheit. Compile this file to a shared library using the command:

          joy> exec gcc -ObjC -bundle -o Thermometer.dll Thermometer.m -framework Foundation

To load the package into the Joy interpreter type:

          joy> load Thermometer.dll

You can then use the Thermometer class within Joy like any other class, e.g:

          joy> set t [Thermometer defaultThermometer]
          Thermometer@0x20ac78
          joy> $t setTemperature: 12.5
          joy> $t temperatureInFahrenheit
          54.5