Missing the plot, maybe?


I’ve just got to Chapter 6 and have input all code word-for-word until the ‘You’re getting sleepy’ section. For some reason, when I launch the app on iPhone, I just get a black screen. I’m guessing that the view is being generated however is somehow hidden and I can’t work out why. Is this something to do with me using the latest Xcode version at all?


I’m using the latest version of Xcode and it’s fine for me. Typing error perhaps?


If you are using Xcode 4.2, make sure this line stays at the top of codeapplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions[/code]:

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
Otherwise you have no initialized window object.


Don’t forget [self.window makeKeyAndVisible]


Follow the tutorial here: http://chrislee.kr/wp/2011/07/24/mainwindow-xib-absence-in-xcode-4-2-beta-4-with-ios-5-sdk/ if you’re using Xcode 4.2. Assuming you’re not using ARC the only thing I had to do in my applicaitonDidFinishLaunching:withOptions: make the last few lines look like:

//self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
//self.window.backgroundColor = [UIColor whiteColor];

[self.window makeKeyAndVisible];
return YES;

And everything worked like a charm. The only other thing you might look at is to make sure all your outlets and delegates have been set in MainWindow.xib correctly. Then I would check to make sure you set the “Main Interface” in the project summery. All of this is covered in the above tutorial.