Game Development Reference
In-Depth Information
piled Header. You're supposed to add the header files of frameworks that rarely or nev-
er change to the prefix header. This causes the framework's code to be compiled in ad-
vance and made available to all your classes. Unfortunately, it also has the disadvant-
age that, if a header added to the prefix header changes, all your code will have to be
recompiled—which is why you should only add header files that rarely or never
For example, the cocos2d.h header file is a good candidate to add to the prefix
header of a cocos2d project, as shown in Listing 2-1 . To create a noticeable increase in
compilation time, your project would need to be reasonably complex, however, so
don't get your stopwatch out just yet. But it's good practice to add cocos2d.h as a
prefix header right away, if only to never have to write #import "cocos2d.h" in
any of your source files again.
Listing 2-1 . Adding the cocos2d.h Header File to the Prefix Header
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "cocos2d.h"
Note The Prefix header files in a Kobold2D project already have the
cocos2d.h added to it, as well as a number of other reasonable header files.
The AppDelegate Class
Every iOS application has one AppDelegate class that implements the UIAp-
plicationDelegate protocol. In our HelloWorld project, it's simply called Ap-
pDelegate .
The AppDelegate is a global concept found in every iOS application. It tracks
state changes of the application by receiving messages from the iOS at certain points in
time. For example, it allows you to determine when the user gets an incoming phone
call or when the application is low on memory. Cocos2d is typically initialized in the
applicationDidFinishLaunching method.
Search Nedrilad ::

Custom Search