0

I'm trying to simply view an empty table on my iPhone simulator (with Xcode 4.2), but somehow I don't know what I did wrong. Right now it shows nothing than a plain white page. Actually It should show me a table.

For note: I'm following the instructions of Big Nerd Ranch's Guide "iPhone Programming", Chapter 10.

So right now I have 4 files of my Homepwner-App:

  • HomepwnerAppDelegate.m
  • HomepwnerAppDelegate.h
  • ItemsViewController.h
  • ItemsViewController.m

the "ItemsViewController" is a Subclass of the UITableViewController.

ItemsViewController.h

# import <UIKit/UIKit.h>

    @interface ItemsViewController : UITableViewController

@end

ItemsViewController.m

isn't filled with interesting stuff right now

HomepwnerAppDelegate.h

# import <UIKit/UIKit.h>

@class ItemsViewController;

@interface HomepwnerAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    ItemsViewController *itemsViewController; }  


@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

HomepwnerAppDelegate.m

#import "HomepwnerAppDelegate.h"
#import "ItemsViewController.h"

@implementation HomepwnerAppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    //Create a ItemsViewController
    itemsViewController = [[ItemsViewController alloc] init];

    //Place ItemsViewController's table view in the window hierarchy
    [window addSubview:[itemsViewController view]];
    [window makeKeyAndVisible];
    return YES;
}

@end

The console says: Homepwner[2400:207] Applications are expected to have a root view controller at the end of application launch

I know that there are already other threads with same error message and lots of them link at the "didFinishLaunchingWithOptions:"- Method, but since they offered so many solutions, I'm quite confused now, especially because I just followed the instructions of the book and nothing more... I've just got the feeling that I declared something wrong. How to solve the problem?

Kirinriki
  • 855
  • 4
  • 12
  • 18
  • Does this SO question help? http://stackoverflow.com/questions/7520971/applications-are-expected-to-have-a-root-view-controller-at-the-end-of-applicati – trojanfoe May 04 '12 at 19:00
  • I already tried out the first one, it doesn't help. Maybe I should invest the time to try out all the answers. – Kirinriki May 04 '12 at 19:01
  • Yeah it's already been answered here for sure. – trojanfoe May 04 '12 at 19:04
  • okay. Since I'm very new to all that stuff, I just don't know much what I'm doing right now. I even don't know what the error message means for me (just a clue) :-( – Kirinriki May 04 '12 at 19:11
  • OK, I would say you need to do some reading :) http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html – trojanfoe May 04 '12 at 19:13
  • true... still so much to learn. Thanks for your link, I'll read through it. – Kirinriki May 04 '12 at 19:17

1 Answers1

0

I don't know what it's worth but, did you try

self.window.rootViewController = itemsViewController;

This is how I've solve it when I had this problem.

Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
  • thanks for your answer! But where to put it inside? I put it into the **didFinishLaunchingWithOptions** but nothing happened right now... I don't get it... Sorry for this dumb question... The reason why I want to view an empty table view is that it's part of a "tutorial" and I need this part to work for continuing. Like I said: I did everything the same way it's described in the tutorial. And since I'm in learning process, I don't know what's the problem. – Kirinriki May 05 '12 at 08:24