|
|
|
|
|
|
|
| PATH |

The Objective-C language defers as many decisions as it can from compile time and link time to run time. Whenever possible, it does things dynamically. This means that the language requires not just a compiler, but also a run-time system to execute the compiled code. The run-time system acts as a kind of operating system for the Objective-C language; it's what makes the language work.
Objective-C programs interact with the run-time system at three distinct levels:
class method, which asks
an object to identify its class; isKindOfClass: and isMemberOfClass:,
which test an object's position in the inheritance hierarchy; respondsToSelector:,
which checks whether an object can accept a particular message; conformsToProtocol:,
which checks whether it conforms to a protocol; and methodForSelector:,
which asks for the address of a method implementation. Methods like
these give an object the ability to introspect about itself.performSelector: and its
companion initiate messages, and alloc produce
a new object properly connected to its class.sel_getUid(), which
returns a method selector for a method name, and objc_msgSend(),
which sends a message to an object-are defined in the Objective-C
run time system described at various places in the text of this
book.Because the NSObject class is at the root of all inheritance hierarchies, the methods it defines are inherited by all classes. Its methods therefore establish behaviors that are inherent to every instance and every class object. However, in a few cases, the NSObject class merely defines a framework for how something should be done; it doesn't provide all the necessary code itself.
For example, the NSObject class defines a description method
that should return an NSString associated with the receiver. If
you define a class of named objects, you can implement a description method
to return the specific character string associated with the receiver.
NSObject's version of the method can't know what that name will
be, so it merely returns the class name as a default.
This chapter looks at three areas where the NSObject class provides a framework and defines conventions, but where you may need to write code to fill in the details:
Other conventions of the NSObject class are described in the NSObject class specification in the Foundation Framework reference.

© 2001 Apple Computer, Inc.
|
|
|
Contact Us | Privacy Notice Copyright © 2000 Apple Computer, Inc. All rights reserved. 1-800-MY-APPLE |