P. 1
The Objective-C Programming Language - Book

The Objective-C Programming Language - Book


|Views: 689|Likes:
Published by Nikunj Soni

More info:

Published by: Nikunj Soni on Dec 01, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF or read online from Scribd
See more
See less


An object-oriented program is typically built from a variety of objects. A program based on the Cocoa
frameworks might useNSMatrix objects,NSWindow objects,NSDictionary objects,NSFont objects,
NSArray objects orNSWindow objects, for example.

In Objective-C, you define objects by defining their class. The class definition is a prototype for a kind of
object; it declares the instance variables that become part of every member of the class, and it defines a set
of methods that all objects in the class can use.



2009-10-19 | © 2009 Apple Inc. All Rights Reserved.


Objects, Classes, and Messaging

The compiler creates just one accessible object for each class, aclassobject that knows how to build new
objects belonging to the class. (For this reason it’s traditionally called a “factory object.”) The class object is
the compiled version of the class; the objects it builds areinstances of the class. The objects that do the
main work of your program are instances created by the class object at runtime.

All instances of a class have the same set of methods, and they all have a set of instance variables cut from
the same mold. Each object gets its own instance variables, but the methods are shared.

By convention, class names begin with an uppercase letter (such as “Rectangle”); the names of instances
typically begin with a lowercase letter (such as “myRectangle”).

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->