Programming with
Objective-C
Contents
Introduction 5
Who Should Read This Document 5
Organization of This Document 6
See Also 6
Why Objective-C? 7
Object-Oriented Programming 8
Data and Operations 8
Interface and Implementation 9
The Object Model 12
The Messaging Metaphor 13
Classes 15
Modularity 16
Reusability 16
Mechanisms of Abstraction 18
Encapsulation 18
Polymorphism 19
Inheritance 20
Class Hierarchies 21
Subclass Definitions 21
Uses of Inheritance 22
Dynamism 23
Dynamic Typing 24
Dynamic Binding 25
Dynamic Loading 27
Structuring Programs 29
Outlet Connections 29
Extrinsic and Intrinsic Connections 30
Activating the Object Network 31
Aggregation and Decomposition 31
Models and Frameworks 32
2010-11-15 | Copyright © 2010 Apple Inc. All Rights Reserved.
2
Contents
Structuring the Programming Task 34
Collaboration 34
Organizing Object-Oriented Projects 35
Designing on a Large Scale 35
Separating the Interface from the Implementation 35
Dividing the Work into Modules 35
Keeping the Interface Simple 36
Making Decisions Dynamically 36
Inheriting Generic Code 36
Reusing Tested Code 36
Document Revision History 38
2010-11-15 | Copyright © 2010 Apple Inc. All Rights Reserved.
3
Figures
Object-Oriented Programming 8
Figure 2-1
Interface and implementation 9
The Object Model 12
Figure 3-1
Figure 3-2
Figure 3-3
An object 12
Objects in a network 13
An inheritance hierarchy 21
Structuring Programs 29
Figure 4-1
Outlets 30
2010-11-15 | Copyright © 2010 Apple Inc. All Rights Reserved.
4
Introduction
An object-oriented approach to application development makes programs more intuitive to design, faster to develop, more amenable to modification, and easier to understand. Most object-oriented development environments consist of at least three parts:
●
A library of objects
●
A set of development tools
●
An object-oriented