tags:

views:

58

answers:

1

I´m going through Apple´s Your First iPhone OS Application tutorial. I´m stuck in the Adding a View Controller Part.

There´s the part that mentions "To make sure you’re still on track, confirm that your HelloWorldAppDelegate class implementation (HelloWorldAppDelegate.m) looks like this:". What follows is a source listing which I´m trying to compile and run.

If i get rid of the line that says [window addSubview:controllersView]; it works. On the other hand If I leave the line i cant get to the white screen when the iphone simulator launches:

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    MyViewController *aViewController = [[MyViewController alloc]
                initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];
    [self setMyViewController:aViewController];
    [aViewController release];

    UIView *controllersView = [myViewController view];
    [window addSubview:controllersView];
    [window makeKeyAndVisible];
}

Why is that?

A: 

I had the same problem and was disappointed to see no answer posted here. I finally figured out that my problem was a misspelling of the name of "mainBundle" in the following line:

MyViewController *aViewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:[NSBundle mainBundle]];

Hope that helps.

Ian