Empty application question


#1

Good to see the posts about Windows-Based application for Xcode 4.2 and iOS 5. I was working around the problem by using a Single View application without a storyboard. That works fine, but today while working through Chapter 7, I suddenly had a question.

On page 140 it is mentioned that the appDelegate (here: HypnoTimeAppDelegate) is connected to the File’s Owner of the MainWindow.xib and that that is the reason why the appDelegate is sent the application:didFinishLaunchingWithOptions: message. Of course I don’t have a MainWindow.xib, but I did have an automatically created HypnoTimeViewController.h, .m and .xib. Just before I read that page, I had deleted those files, since IMHO they were not used and I wanted to remove any confusion they might create. If I read the post correctly, it is now recommended to use the Empty Application, where you don’t have a XIB to begin with, so my action seems to be okay.

My question: my appDelegate works fine and is sent the message, so did I not understand that sentence in the book correctly? Or did they change this for iOS 5? Or is there another reason my appDelegate gets the message without having the connection to a XIB?

Thanks for helping me out!


#2

The UIApplication object will send application:didFinishLaunchingWithOptions: to its delegate. In the Window-Based Application template, the delegate was set in the XIB file. In an empty application, delegate is actually set in the main function.

UIApplicationMain(argc, argv, nil, [AppDelegate class]);

This function creates an instance of UIApplication, then creates an instance of AppDelegate, then sets the instance of AppDelegate to be the delegate of the UIApplication. It’s all happening - just in different places.


#3

Thanks!
I knew it was happening, since it compiled and ran well, but just overlooked main.m.
Guess I have to get used to so many files that contain small bits. I’ve never programmed projects like these before.