3
How This Book Is Organized
So I decided neither to teach C first nor to assume prior knowledge of the language.
Instead, I decided to take the unconventional approach of teaching Objective-C and the
underlying C language as a single integrated language, from an object-oriented program-
ming perspective.The purpose of this book is as its name implies: to teach you how to
program in Objective-C. It does not profess to teach you in detail how to use the devel-
opment tools that are available for entering and debugging programs, or to provide in-
depth instructions on how to develop interactive graphical applications.You can learn all
that material in greater detail elsewhere, after you’ve learned how to write programs in
Objective-C. In fact, mastering that material will be much easier when you have a solid
foundation of how to program in Objective-C.This book does not assume much, if any,
previous programming experience. In fact, if you’re a novice programmer, with some
dedication and hard work you should be able to learn Objective-C as your first program-
ming language. Other readers have been successful at this, based on the feedback I’ve
received from the previous editions of this book.
This book teaches Objective-C by example.As I present each new feature of the lan-
guage, I usually provide a small complete program example to illustrate the feature. Just as
a picture is worth a thousand words, so is a properly chosen program example.You are
strongly encouraged to run each program (all of which are available online) and compare
the results obtained on your system to those shown in the text. By doing so, you will
learn the language and its syntax, but you will also become familiar with the process of
compiling and running Objective-C programs.
How This Book Is Organized
This book is divided into three logical parts. Part I,“The Objective-C Language,” teaches
the essentials of the language. Part II, “The Foundation Framework,” teaches how to use
the rich assortment of predefined classes that form the Foundation framework. Part III,
“Cocoa, Cocoa Touch, and the iOS SDK,” gives you an overview of the Cocoa and
Cocoa Touch frameworks and then walks you through the process of developing a simple
iOS application using the iOS SDK.
A framework is a set of classes and routines that have been logically grouped together to
make developing programs easier. Much of the power of programming in Objective-C
rests on the extensive frameworks that are available.
Chapter 2,“Programming in Objective-C,” begins by teaching you how to write your
first program in Objective-C.
Because this is not a book on Cocoa or iOS programming, graphical user interfaces
(GUIs) are not extensively taught and are hardly even mentioned until Part III. So an
approach was needed to get input into a program and produce output. Most of the exam-
ples in this text take input from the keyboard and produce their output in a window
pane: a Terminal window if you’re using the command line, or a debug output pane if
you’re using Xcode.
Chapter 3,“Classes, Objects, and Methods,” covers the fundamentals of object-oriented
programming.This chapter introduces some terminology, but it’s kept to a minimum. I