Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Programmer's Guide to MacApp / Part 2 - Working With MacApp
Chapter 10 - Working With Objects


Overview

MacApp's TObject class provides basic services that are needed by most objects. Most of the classes in the MacApp class library descend from TObject, as do most of the classes in a typical MacApp application.

The TObject class defines a minimum of instance variables. It provides methods to

This chapter describes how you define subclasses of TObject and other MacApp classes and how you instantiate objects.

Choosing an Object Class

Your application creates objects based on classes defined by MacApp and on classes you define. Figure 10-1 shows the MacApp classes your application is most likely to create subclasses for. Many of the objects you create fall into one of these categories:

Figure 10-1 Classes defined by most MacApp applications

The MacApp Class and Method Reference lists all the classes and methods provided by MacApp.

Creating Objects

Every MacApp application creates objects and initializes them, then deletes and frees them when they are no longer needed. MacApp provides a mechanism for creating an object safely and ensuring that the object is freed correctly. This mechanism is described in detail in "Initializing and Freeing Objects," beginning on page 36, and in "Creating and Deleting Objects," beginning on page 38.

Providing Runtime Type Information for a Class

MacApp provides a number of macro definitions to help TObject (and your classes based on TObject) supply dynamic information about an object's class hierarchy. This information is known as runtime type information, or RTTI, and is described in detail in Chapter 2, "Basic Operations." Chapter 2 lists the reasons a particular class may need RTTI.

The recipes that follow describe how to define classes, and how to instantiate, initialize, and free objects based on those classes. Although the recipes show how to include RTTI, some classes you define may not require it.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
25 JUL 1996