Thursday, July 22, 2010

Programming in Object-C 2.0

This book is divided into three logical parts. Part I,“The Objective-C 2.0 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 Programming and the iPhone SDK,” gives you an overview of Cocoa’s Application
Kit framework and then walks you through the process of developing a simple
iPhone application using the UIKit framework, and developing and debugging the code
with Xcode and Interface Builder.
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 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 examples in this
text take input from the keyboard and produce their output in a window: a Terminal
window if you’re using gcc from the command line, or a Console window 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 also introduce the mechanism for defining a class and the means for sending
messages to instances or objects. Instructors and seasoned Objective-C programmers will
notice that I use static typing for declaring objects. I think this is the best way for the student
to get started because the compiler can catch more errors, making the programs
more self-documenting and encouraging the new programmer to explicitly declare the
data types when they are known.As a result, the notion of the id type and its power is not
fully explored until Chapter 9,“Polymorphism, Dynamic Typing, and Dynamic Binding.”

Chapter 4,“Data Types and Expressions,” describes the basic Objective-C data types
and how to use them in your programs.
Chapter 5,“Program Looping,” introduces the three looping statements you can use in
your programs: for, while, and do.
Making decisions is fundamental to any computer programming language. Chapter 6,
“Making Decisions,” covers the Objective-C language’s if and switch statements in detail.
Chapter 7,“More on Classes,” delves more deeply into working with classes and objects.
Details about methods,multiple arguments to methods, and local variables are discussed
here.
Chapter 8,“Inheritance,” introduces the key concept of inheritance.This feature makes
the development of programs easier because you can take advantage of what comes from
above. Inheritance and the notion of subclasses make modifying and extending existing
class definitions easy.
Chapter 9 discusses three fundamental characteristics of the Objective-C language.
Polymorphism, dynamic typing, and dynamic binding are the key concepts covered here.
Chapters 10–13 round out the discussion of the Objective-C language, covering issues
such as initialization of objects, protocols, categories, the preprocessor, and some of the
underlying C features, including functions, arrays, structures, and pointers.These underlying
features are often unnecessary (and often best avoided) when first developing objectoriented
applications. It’s recommended that you skim Chapter 13,“Underlying C
Features,” the first time through the text and return to it only as necessary to learn more
about a particular feature of the language.
Part II begins with Chapter 14,“Introduction to the Foundation Framework,” which
gives an introduction to the Foundation framework and how to access its documentation.
Chapters 15–19 cover important features of the Foundation framework.These include
number and string objects, collections, the file system, memory management, and the
process of copying and archiving objects.
By the time you’re done with Part II, you will be able to develop fairly sophisticated
programs in Objective-C that work with the Foundation framework.
Part III starts with Chapter 20,“Introduction to Cocoa.” Here you’ll get a quick
overview of the Application Kit that provides the classes you need to develop sophisticated
graphical applications on the Mac.
Chapter 21,“Writing iPhone Applications,” introduces the iPhone SDK and the UIKit
framework.This chapter illustrates a step-by-step approach to writing a simple iPhone (or
iTouch) application, followed by a calculator application that enables you to use your
iPhone to perform simple arithmetic calculations with fractions.
Because object-oriented parlance involves a fair amount of terminology,Appendix A,
“Glossary,” provides definitions of some common terms.
Appendix B,“Objective-C Language Summary,” gives a summary of the Objective-C
language, for your quick reference.
Appendix C,“Address Book Source Code,” gives the source code listing for two classes
that are developed and used extensively in Part II of this text.These classes define address card and address book classes. Methods enable you to perform simple operations such as
adding and removing address cards from the address book, looking up someone, listing
the contents of the address book, and so on.
After you’ve learned how to write Objective-C programs, you can go in several directions.
You might want to lean more about the underlying C programming language—or
you might want to start writing Cocoa programs to run on Mac OS X, or develop more
sophisticated iPhone applications. In any case,Appendix D,“Resources,” will guide you in the right direction.
Download

No comments: