The Objective-C 2.0 Programming Language
PDF
Introduction
Objects, Classes, and Messaging
Runtime
Objects
Object Basics
id
Dynamic Typing
Memory Management
Object Messaging
Message Syntax
Sending Messages to nil
The Receiver’s Instance Variables
Polymorphism
Dynamic Binding
Dynamic Method Resolution
Dot Syntax
Using the Dot Syntax
Overview
General Use
nil Values
self
Performance and Threading
Usage Summary
Incorrect Use
Classes
Inheritance
The NSObject Class
Inheriting Instance Variables
Inheriting Methods
Overriding One Method With Another
Abstract Classes
Class Types
Static Typing
Type Introspection
Class Objects
Creating Instances
Customization With Class Objects
Variables and Class Objects
Initializing a Class Object
Methods of the Root Class
Class Names in Source Code
Testing Class Equality
Defining a Class
Source Files
Class Interface
Importing the Interface
Referring to Other Classes
The Role of the Interface
Class Implementation
Referring to Instance Variables
The Scope of Instance Variables
Messages to self and super
An Example
Using super
Redefining self
Allocating and Initializing Objects
Allocating and Initializing Objects
The Returned Object
Implementing an Initializer
Constraints and Conventions
Handling Initialization Failure
Coordinating Classes
The Designated Initializer
Combining Allocation and Initialization
Declared Properties
Overview
Property Declaration and Implementation
Property Declaration
Property Declaration Attributes
Accessor Method Names
Writability
Setter Semantics
Atomicity
Markup and Deprecation
Property Implementation Directives
Using Properties
Supported Types
Property Re-declaration
Copy
dealloc
Core Foundation
Example
Subclassing with Properties
Performance and Threading
Runtime Difference
Categories and Extensions
Adding Methods to Classes
How you Use Categories
Categories of the Root Class
Extensions
Protocols
Declaring Interfaces for Others to Implement
Methods for Others to Implement
Declaring Interfaces for Anonymous Objects
Non-Hierarchical Similarities
Formal Protocols
Declaring a Protocol
Optional Protocol Methods
Informal Protocols
Protocol Objects
Adopting a Protocol
Conforming to a Protocol
Type Checking
Protocols Within Protocols
Referring to Other Protocols
Fast Enumeration
The for…in Feature
Adopting Fast Enumeration
Using Fast Enumeration
Enabling Static Behavior
Default Dynamic Behavior
Static Typing
Type Checking
Return and Argument Types
Static Typing to an Inherited Class
Selectors
Methods and Selectors
SEL and @selector
Methods and Selectors
Method Return and Argument Types
Varying the Message at Runtime
The Target-Action Design Pattern
Avoiding Messaging Errors
Exception Handling
Enabling Exception-Handling
Exception Handling
Catching Different Types of Exception
Throwing Exceptions
Threading
Synchronizing Thread Execution
Remote Messaging
Distributed Objects
Language Support
Synchronous and Asynchronous Messages
Pointer Arguments
Proxies and Copies
Using C++ With Objective-C
Mixing Objective-C and C++ Language Features
C++ Lexical Ambiguities and Conflicts
Limitations
Appendix A: Language Summary
Messages
Defined Types
Preprocessor Directives
Compiler Directives
Classes
Categories
Formal Protocols
Method Declarations
Method Implementations
Deprecation Syntax
Naming Conventions
Glossary
Revision History
Index