Game Development Reference
In-Depth Information
Everything that happens between the main function and the AppDelegate class is
part of the behind-the-scenes magic of the iOS SDK, over which you have no control.
because you'll practically never need to change main.m , you can safely ignore its
contents. Still, it never hurts to peek inside.
The main function creates an @autoreleasepool and then calls UIApplica-
tionMain to start the application using AppController as the class that imple-
ments the UIApplicationDelegate protocol. You can find the implementation of
the AppController class in the files named AppDelegate . This is what the main
function looks like in an ARC-enabled cocos2d application:
int main(int argc, char *argv[])
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
return retVal;
The only interesting point to take away from this is that every iOS application uses an
@autoreleasepool , which ARC needs to manage memory.
In Kobold2D apps, the main function only calls KKMain which performs the preced-
ing and ends up using the AppDelegate class as well. But KKMain also initializes
Lua, loads the config.lua file, and calls the appropriate startup function depending
on the operating system (iOS or Mac OS).
int main(int argc, char *argv[])
// Forward main to a default implementation provided by Kobold2Dâ„¢.
return KKMain(argc, argv, NULL);
The Prefix Header Files
In case you're wondering what the Prefix.pch header files are for, they're special
header files used to speed up compilation. The PCH abbreviation stands for Pre-Com-
Search Nedrilad ::

Custom Search