A-92C, 3
rd
& 4
th
FLOOR, TAIMOOR NAGAR, NEW FRIENDS COLONY,
NEW DELHI – 110065; PH: +91-11-65189464
EMAIL: info@metaoption.com
: WEB SITE: www.metaoption.com
Cocoa Framework for Mac
[By: Mac Team METAOPTION]
A-92C, 3
rd
& 4
th
FLOOR, TAIMOOR NAGAR, NEW FRIENDS COLONY,
NEW DELHI – 110065; PH: +91-11-65189464
EMAIL: info@metaoption.com
: WEB SITE: www.metaoption.com
Introduction
This article mainly refers the basics of cocoa and how objective C works in
cocoa framework and the user interfaces with interface builder.
Cocoa
Cocoa is an object-oriented application environment designed specifically for
developing Mac OS X native applications. The Cocoa frameworks support
rapid development and high productivity, and include a full-featured set of
classes designed to create robust and powerful Mac OS X applications.
Cocoa provides developers starting new Mac OS X projects the fastest way
to full-featured, extensible, and maintainable implementations. Applications
from UNIX and other platforms can also be brought to Mac OS X quickly by
using Cocoa to build state-of-the-art Aqua user interfaces while retaining
most existing core code.
Object Oriented Programming with Objective-C
Cocoa is pervasively object-oriented, from its paradigms to its event-driven
architecture. Objective-C, the primary development language for Cocoa, is
thoroughly object-oriented too, despite its grounding in ANSI C. It provides
runtime support for message dispatch and specifies syntactical conventions
for defining new classes. Objective-C supports most of the abstractions and
mechanisms found in other object-oriented languages such as C++ and Java.
These include inheritance, encapsulation, reusability, and polymorphism.
But Objective-C is different from these other object-oriented languages,
often in important ways. For example, Objective-C, unlike C++, doesn’t allow
operator overloading, templates, or multiple inheritance. Objective-C also
doesn’t have a “garbage collection” mechanism—such as Java’s—that
A-92C, 3
rd
& 4
th
FLOOR, TAIMOOR NAGAR, NEW FRIENDS COLONY,
NEW DELHI – 110065; PH: +91-11-65189464
EMAIL: info@metaoption.com
: WEB SITE: www.metaoption.com
automatically frees unneeded objects (although it has mechanisms and
conventions for accomplishing the same thing.
Although Objective-C doesn’t have these features, its strengths as an object-
oriented programming language more than compensate. What follows is an
exploration of the special capabilities of Objective-C as well as an overview of
the Cocoa version of the Java programming language.
Root Class and Message Mapping
NSObject is the root class of most Objective-C class hierarchies; it has no
superclass. From NSObject, other classes inherit a basic interface to the run-
time system for the Objective-C language, and its instances obtain their
ability to behave as objects.
Although it is not strictly an abstract class, NSObject is virtually one. By
itself, an NSObject instance cannot do anything useful beyond being a simple
object. To add any attributes and logic specific to your program, you must
create one or more classes inheriting from NSObject or from any other class
derived from NSObject.
NSObject, along with java.lang.Object, is the root class for all things Cocoa in
Java, including Foundation and Application Kit.
NSObject is the name not only of a class but of a protocol. Both are essential
to the definition of an object in Cocoa. The NSObject protocol specifies the
basic programmatic interface required of all root classes in Cocoa; thus not
only the NSObject class adopts the identically named protocol, but the other
Cocoa root class, NSProxy, adopts it as well. The NSObject class further
specifies the basic programmatic interface for any Cocoa object that is not a
proxy object.
A protocol such as NSObject is used in the overall definition of Cocoa objects