Graphics Reference
In-Depth Information
Create the Xcode Project
To create our application, follow these steps:
1.
In Xcode, press Shift-
„
-N and select Cocoa Application in the Project Templates
dialog.
2.
Name the project
CA Basics
and click Save.
3.
Expand the Frameworks group, Control-click the Linked Frameworks subgroup, and
select
Add > Existing Frameworks
.
4.
In the resulting dialog, navigate to
/System/Library/Frameworks
and select
QuartzCore.framework
. Click Add twice, as prompted.
5.
Control-click the Classes group and select
Add > New File
.
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.
Select
AppDelegate.h
to open the file in the code editor and add the following code:
@interface
AppDelegate :
NSObject
{
IBOutlet
NSWindow *window;
}
9.
Select
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
XIB in Interface Builder.
11.
From the Library palette in Interface Builder, drag an
NSObject
object into
MainMenu.xib
and rename it to
AppDelegate
.
12.
Make sure the
AppDelegate
object is selected. In the object inspector, click the
Identity tab and change the Class field to AppDelegate.
13.
In the
MainMenu.xib
, Control-click on File's Owner and drag the connection to the
AppDelegate object. Select delegate in ensuing context menu.