Copyright ©1999 by AAA+ Software Forschungs- und Entwicklungs Ges.m.b.H.  All Rights Reserved.  Revision 2.1 - Mar 25, 1999.



Joy Studios Example

This example is based on Apple's standard EOF example 'Studios.app' which ships with OS X Server. It demonstrates that you can execute your standard Objective-C code in Joy's interpreted environment. It shows that your users won't notice any performance hit as a result of your use of Joy. And most importantly, it shows you how you can save time on your EOF development projects.

Just copy your Objective-C code across!

We're going to take a look at how easy it is to run a standard Objective-C application as a Joy application. We're going to use Apple's EOF "Studio" example. The original can be found on your Windows harddisk under $NEXT_ROOT (probably C:\Apple. For the rest of this document, paths are assumed to be under $NEXT_ROOT):

     /System/Developer/Examples/EnterpriseObjects/AppKit/Studios

Please note the following things:

If you want to work through the simple steps we did in order to prepare this example, here's what you do:
  1. Create a blank Joy application. Open InterfaceBuilder and select New Joy Application from the Joy menu. This creates a new, blank, application, with a Joy interpreter.
  2. Save the application, using Joy's Save Nib as App... menu item. Call it "JoyStudios". This saves the InterfaceBuilder file directly as an executable application. If you like, you can even save it as a cross-platform, Windows and OS X Server, application. Creating an executable without Joy requires using ProjectBuilder.
  3. Look into the application wrapper. Applications are stored as folders, with lots of resources inside. As a user of the application, you don't see this. The source files that Joy uses for the implementation of the program's functionality are resources. In order to see what is inside the application wrapper click on JoyStudio.app. For Mac OS X Server, bring up the Contents Inspector (in Workspace Manager's Tools Menu). Click on the inspector's Open Application Wrapper... button. For Windows, simply double-click on the directory. UNIX-START
  4. Copy the interface files for Apple's example to the new application. You can do this by picking up the English.lproj folder from the Studios example with the mouse and dragging it into the Resources folder inside JoyStudio's application wrapper. When asked what to do with the existing folder, click on Replace. Inside this newly-copied English.lproj folder, rename the NIB file from Studios.nib to JoyStudios.nib . If you like, you can also add a menu item to give you access to the Joy command window from the running application. UNIX-END WINDOWS-START
  5. Copy the interface files for Apple's example to the new application. You can do this by picking up the English.lproj folder from the Studios example with the mouse and dragging it into the Resources folder inside JoyStudio's application wrapper. When asked what to do with the existing folder, click on Replace. Inside this newly-copied English.lproj folder, rename the NIB file from Studios-windows.nib to JoyStudios-windows.nib. If you like, you can also add a menu item to give you access to the Joy command window from the running application. WINDOWS-END
  6. Copy the EO Model file. This application is an Enterprise Objects Framework application. Therefore, it uses an EOModel file. Copy this file (MoviesAppKit.eomodeld) across from the original application to the new one. (Just put it straight into the Resources folder.)
          
    The Apple example has a bug that prevents the two Objective-C source files Studio.m and Talent.m from ever being used by the application. Instead it uses Java classes installed in /Local/Library/Frameworks. Fix this by opening the MoviesAppKit.eomodeld file with EOModeler and changing the class names for the Studio and Talent entities from businesslogic.server.Studio and businesslogic.server.Talent to just Studio and Talent. Alternatively you can just copy the MoviesAppKit.eomodeld from the finished example cited above.

    There is another bug in the original example that causes the program to crash if you buy a movie with a null revenue. Surely you will have no difficulty fixing it!
  7. Copy all of the original example's .h and .m files into the Resources folder. You do not need to edit these -- Joy just interprets the Objective-C!
  8. Finally write some code! Open up the main.js file and add a few lines to load in the required frameworks, as well as the Objective-C source files. Look at the finished example to see how to do this!
And that's it! The application works (no compilation needed)!

Note that the files you copied across weren't changed. Because of this, you don't actually need to copy them, you could instead just link to wherever they currently are in your project source tree.

More information

See the tutorial section "Objective-C compatibility" for more information.



Document created by Adrian Smith of AAA+ Software
19 January 1999