Graphics Reference
In-Depth Information
6.
In the New File template dialog, select
Objective-C class
under the Cocoa group
and click Next.
7.
Name the file
AppDelegate.m
and make sure Also Create “AppDelegate.h” is checked.
Click Finish.
8.
Click
AppDelegate.h
to open the file in the code editor and add the following code:
@interface
AppDelegate : NSObject {
IBOutlet
NSWindow *window;
}
9.
Click
AppDelegate.m
to open the file in the code editor and add the following code:
@implementation
AppDelegate
- (
void
)awakeFromNib;
{
[[window
contentView
] setWantsLayer:
YES
];
}
@end
10.
Under the Resources group in your project, double-click
MainMenu.xib
to open the
nib in Interface Builder.
11.
From the Library palette, drag an
NSObject
object into
MainMenu.xib
and rename it
to
AppDelegate
.
12.
Make sure your
AppDelegate
object is selected. In the object inspector, click the
Identity tab and change the Class field to
AppDelegate
.
13.
In
MainMenu.xib
, Control-click on File's Owner and drag the connection to the
AppDelegate
object. Select
delegate
in the ensuing context menu.
14.
In the
MainMenu.xib
, Control-click on
AppDelegate
and drag the connection to the
Window object. Select
window
in the ensuing context menu.
15.
Save the XIB file and return to Xcode.
The project is now set up. In the preceding steps we created an application delegate that
we can use to provide functionality between our views and our data. In the next section,
we demonstrate how to implement adding a Quartz Composition layer,
QCCompositionLayer
, to our window.
Adding a QCCompositionLayer to the Window
Now that we have an outlet defined for the window in the
AppDelegate
class, we can add
the
QCCompositionLayer
to the root layer of the window's content view. Listing 9-1
demonstrates how this is done in our
-awakeFromNib
method.