-
Notifications
You must be signed in to change notification settings - Fork 109
Cocoa in 2 Minutes
You are here: Home → Documentation → Mac information page → Sc21 → Cocoa in 2 Minutes
Cocoa
So, what is Cocoa? Together with Carbon, Cocoa is one of the two basic frameworks on Mac OS X. If you write an application with a graphical user interface, you will - directly or indirectly - either use Carbon or Cocoa. Cocoa itself contains several frameworks, the most important of them being Foundation and AppKit. The Foundation framework is a collection of basic types and useful utilities; it contains for instance a string class, a dictionary, and so on. The AppKit framework provides user interface elements such as views, buttons, and the like.
Objective-C
The language of Cocoa is Objective-C. Objective-C, is an extension to C to add object-orientated capabilities to the language. Objective-C is very dynamic and run-time based, conceptually much closer to Smalltalk or Python than C++.
It is possible to mix Objective-C and C++. The result is Objective-C++. In Objective-C++, you can have both C++ and Objective-C objects. Objective-C objects can have pointers to C++ objects, call methods on them, &c.; - and vice versa. At the same time, the runtimes are completely separate (so you cannot e.g. derive an Objective-C class from a C++ class.)
Objective-C++ makes it possible to write programs in Objective-C while keep using existing C++ code.
Nib Files
Another interesting feature of Cocoa is the concept of Nib files. In short, Nib files are archives of serialized objects. At application startup, these files are unarchived and the objects in them re-instantiated.
Typically when creating a Cocoa application, you will design its GUI in a tool called Interface Builder. It is quite common to have a graphical IDE to design GUIs; but most of these generate source code or a textual descriptions of the interface. Interface Builder actually saves the objects - the windows, views, menu items etc.