HelloWorldCompiled
The HelloWorldCompiled application is a modification of the HelloWorld application. It's designed to show you how to integrate custom Objective-C objects into a WebObjects application and how to use Objective-C to compile your components.
Notable Components
- Main
- The Main component is specified by a template file (Main.html), a declarations file (Main.wod), and an Objective-C class (defined in Main.h and Main.m). When a request is made for the Main page, WebObjects finds (or instantiates) an object of the Main class, which in turn uses the template and declarations file to determine the HTML representation to send to the browser. When the user interacts with the page and then submits it, the Main object's sayHello method is invoked, creating the next page.
- Hello
- The Hello component is similar in design to the Main component, being specified by a template file (Hello.html), a declarations file (Hello.wod), and an Objective-C object (defined in Hello.h and Hello.m). It's function is to display a page containing the name passed in from the Main page.
Interesting Issues
Memory Management
A scripted application (like HelloWorld) automatically deallocates script variables when they're no longer needed. When you create components with compiled code (as in HelloWorldCompiled), you have to provide a method that will deallocate these variables when the object that owns them is itself deallocated. See the dealloc method in Main.m and Hello.m.