Programming Mac OS X with Cocoa for Beginners 2nd Edition/What Is Cocoa?
The Cocoa FrameworkEdit
Cocoa is a modern, object-oriented framework. The Cocoa framework contains the class definitions for classes that are generally useful to produce a graphical user interface (GUI) for applications to be run under Mac OS X. Cocoa also provides an object-oriented interface to the operating system (OS). Cocoa is what Apple itself uses to develop Mac apps that come with Mac OS X such as Finder, Mail, iTunes, etc.
To use Cocoa in your apps, you import "Cocoa.h". The following code is from the file, "Cocoa.h". Go ahead and read the comment and the code.
#import <Foundation/Foundation.h> #import <AppKit/AppKit.h> #import <CoreData/CoreData.h>
Generally, for all our projects in this wikibook, we will import Cocoa.h with the following code:
Note that #import does something similar to what #include does in C. #import includes the specified file, but unlike #include in C, you don't have to worry about a file including itself or a file being included twice. The compiler takes care of that and just does the right thing. So, in this wikibook, we'll always use #import instead of #include, but keep in mind that Objective-C can do anything that C can do so #include would still work in any C code that used #include. You can mix C and Objective-C any which way.
Now looking at what is imported, Cocoa.h imports the interface to the Foundation Framework, the interface to the AppKit Framework, and the interface to the CoreData FrameWork. We'll cover these frameworks a little more later in this wikibook, but for now, you can just think of the Cocoa Framework as being built on top of these three other frameworks.
Cocoa is an example of an application programming interface or API. Apple used to support two older APIs for Mac OS X, "Classic" and "Carbon", but these were both for backward compatibility applications developed for "Classic Mac OS", that is for versions of Mac OS before Mac OS X. If you read about the Classic API or the Carbon API and framework, just know that these are both history.
What Frameworks Are Available?Edit
Where Are Frameworks Located?Edit
You can find the Cocoa framework, and many other frameworks from Apple in the System folder.
Boot Volume → System → Library → Frameworks → Cocoa.framework
You can look around inside of the System Folder and get an idea of what's there, but don't change anything there.
Third-party frameworks should be installed in the following location:
Volume → Library → Frameworks
There is one more place where frameworks might be and that is in the Developer directory:
Boot Volume → Developer → Library → Framework