Tiny.m Revisited
Now let’s take another look at
Tiny.m
. Here is the start of the
Tiny.m program:
/* Tiny.m * A tiny Cocoa application that creates a window * and then displays graphics in it. */
Like any well-written program, Tiny.m begins
with a set of comments describing what the program does. Objective-C
supports the standard ANSI C style of comments. That means that
anything enclosed between a /* and a
*/ is a comment. Anything on a line following a
double forward slash (//
) is a comment as well. Thus:
/* This is a comment */ // This is a comment as well
The next line of Tiny.m imports the Cocoa header
files for the Foundation and Application Kit frameworks:
#import <Cocoa/Cocoa.h>
This statement brings in the Objective-C class definitions for the entire Cocoa framework, including the Foundation and the Application Kit. Recall from earlier chapters that the Foundation is a collection of tremendously useful classes for managing strings, arrays, queues, and other traditional data structures. The Application Kit is the collection of classes that are used to display the graphical user interface; often called the AppKit, this framework includes the fundamental NSApplication, NSWindow, and NSView classes.
Tip
You might think that importing such a large number of files would
slow down the compilation process. In fact, it does not, because all
of the Cocoa
headers are precompiled. As
long as you #import
<Cocoa/Cocoa.h> before you do anything else in your program, the required time ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access