Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Classes and Objects

An object consists of both data and methods for manipulating that data. An object is an instance of a class, which means that there is memory allocated for that specific instance of the class. An essential characteristic of objects is that they encapsulate data. Other objects or external code cannot access the object’s data directly, but they request data from the object by sending messages to it. Read that sentence again, as it speaks from the very heart of object-oriented development. Other objects or external code cannot access the object’s data directly, but they request data from the object by sending messages to it. Your job is to make those objects talk to one another and share information through their methods.

An object invokes methods corresponding to messages that are passed to it and may return data to whoever sent the message. An object’s methods do the encapsulating, in effect, regulating access to the object’s data. An object’s methods are also its interface, articulating the ways in which the object communicates with the outside world.

Because an object encapsulates a defined set of data and logic, you can easily assign it to particular duties within a program. Conceptually, it is like a functional unit—for instance, “customer Record”—that you can move around on a design board; you can then plot communication paths to and from other objects based on their interfaces.

When designing an object-oriented application, it is often helpful to depict the relationships between objects graphically. This document depicts objects graphically as shown in Figure 1-1.


Figure 1-1  An object

An object as a jelly donut

See The Objective-C 2.0 Programming Language for a fuller description of data encapsulation, messages, methods, and other things pertaining to object-oriented programming.



< Previous PageNext Page > Hide TOC


Last updated: 2007-10-31




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice