Graphics Reference
In-Depth Information
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
to import the QuartzCore framework and to create an outlet to the window in your
XIB:
#import <QuartzCore/QuartzCore.h>
@interface AppDelegate : NSObject
{
IBOutlet NSWindow *window;
}
9. Select AppDelegate.m to open the file in the code editor and add the following
code to turn on layer backing for your window's contentView :
@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, drag an NSObject object into MainMenu.xib and rename it
AppDelegate . You need to be in icon view to rename the object. Click once to select
the object. Pause and then click it again to place it in edit mode. Then you can
rename the object.
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.
This setup is the foundation for all the projects we create on OS X. From this template,
you can add actions and outlets that connect your controls in the XIB to a reference in
your AppDelegate class. We refer to these steps for setting up your OS X-based projects
throughout this topic.
Search WWH ::




Custom Search