Building iPhone/iPad applications without Interface Builder
If you are wondering how to decouple Interface Builder from the development cycle and only use XCode when starting a new iPhone or iPad application, it's very easy to do:
- Create a new project in XCode
- under 'Resources' remove MainWindow.xib
- under 'Other Sources' edit main.m, change the fourth argument of this call:
UIApplicationMain(argc, argv, nil, nil) to the name of your application delegate, e.g. UIApplicationMain(argc, argv, nil, @"MyAppDelegate") - Now you just need to make sure your application creates and shows a window, this was part of the MainWindow.xib we deleted in step (2) and now we'll need to do this ourselves (see the code snippet below)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIWindow *newWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[newWindow makeKeyAndVisible];
}
Note that this exact implementation does not release the created window, you'll typically want to store a reference in a class-level variable and release it when deallocating.



0 Comments:
Post a Comment
<< Home