Bookmark and Share

Tuesday, 10 August 2010


Cocoa is one of Apple Inc.’s native object-oriented application program environments for the Mac OS X operating system. It is one of five major APIs available for Mac OS X; the others are Carbon, POSIX (for the BSD environment), X11 and Java.

Cocoa applications are typically developed using the development tools provided by Apple, specifically Xcode (formerly Project Builder) and Interface Builder, using the Objective-C language. However, the Cocoa-programming environment can be accessed using other tools, such as Object Pascal, Python, Perl and Ruby, with the aid of bridging mechanisms such as PasCocoa, PyObjC, CamelBones and RubyCocoa, respectively. Also, under development by Apple, is an implementation of the Ruby language, called MacRuby, which does away with the requirement for a bridging mechanism. It is also possible to write Objective-C Cocoa programs in a simple text editor and build it manually with GCC or GNUstep’s makefile scripts. For end-users, Cocoa applications are considered to be those written using the Cocoa-programming environment. Such applications usually have a distinctive feel, since the Cocoa-programming environment automates many aspects of an application to comply with Apple’s human interface guidelines.

Main frameworks

Cocoa consists primarily of two Objective-C object libraries called frameworks. Frameworks are functionally similar to shared libraries, a compiled object that can be dynamically loaded into a program’s address space at runtime, but frameworks add associated resources, header files, and documentation.

Foundation Kit, or more commonly simply Foundation, first appeared in OpenStep. On Mac OS X, it is based on Core Foundation. Foundation is a generic object-oriented library providing string and value manipulation, containers and iteration, distributed computing, run loops, and other functions that are not directly tied to the graphical user interface. The “NS” prefix, used for all classes and constants in the framework, comes from Cocoa’s NeXTSTEP heritage.

Application Kit or AppKit is directly descended from the original NeXTSTEP Application Kit. It contains code with which programs can create and interact with graphical user interfaces. AppKit is built on top of Foundation, and uses the same “NS” prefix. A key part of the Cocoa architecture is its comprehensive views model. This is organized along conventional lines for an application framework, but is based on the PDF drawing model provided by Quartz. This allows creation of custom drawing content using PostScript-like drawing commands, which also allows automatic printer support and so forth. Since the Cocoa framework manages all the clipping, scrolling, scaling and other chores of drawing graphics, the programmer is freed from implementing basic infrastructure and can concentrate only on the unique aspects of an application’s content.

Technology Overview

Cocoa helps you create commercial-grade applications quickly and efficiently. It is an advanced, mature object- oriented development environment that enables you to create complex software with surprisingly few lines of code. Through a seamless integration of tools and Cocoa API, the design and construction of a user interface is largely a matter of dragging windows, buttons, and other objects from palettes, initializing their attributes, and connecting them to other objects. Cocoa also defines a model for applications and implements most aspects of application behavior; you simply fit into this model the code that makes your application unique.

The programmatic interfaces of the core Cocoa frameworks, Foundation and Application Kit, simplify access to most of the technologies on which Mac OS X is based, such as Quartz, Bonjour networking, Core Text, and the printing system. Although these interfaces are in Objective-C, you can integrate code written in other languages into your Cocoa projects, including C++ code and C code. Because Objective-C is a superset of ANSI C, frameworks with C APIs are compatible with Objective-C.


The Cocoa frameworks are written in Objective-C, and hence Objective-C is the preferred language for development of Cocoa applications. Java bindings for the Cocoa frameworks (known as the “Java bridge”) are also available but have not proven popular amongst Cocoa developers. Further, the need for runtime binding means many of Cocoa’s key features are not available with Java. In 2005, Apple announced that the Java bridge was to be deprecated, meaning that features added to Cocoa in Mac OS X versions later than 10.4 would not be added to the Cocoa-Java programming interface. AppleScript Studio, part of Apple’s Xcode Tools makes it possible to write (less complex) Cocoa applications using AppleScript. Third party bindings available for other languages include PyObjC (Python), RubyCocoa (Ruby), CamelBones (Perl), Cocoa#, Monobjc (C#) and NObjective(C#).There are also open source implementations of major parts of the Cocoa framework that allows cross- platform (including Microsoft Windows) Cocoa application development, such as GNUstep, and Cocotron


Post a Comment

There was an error in this gadget