TableView not displaying - fix


#1

To further illustrate what i mean, this is how the itemsViewController is set as the rootViewController in the Chapter 10 code examples for the method application:didFindishLaunching WithOptions:

[code] - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.

//create an items view controller

itemsViewController = [[ItemsViewController alloc] init];

//Place items view controller’s tabel view in the window hierarchy
[window setRootViewController: itemsViewController];

[self.window makeKeyAndVisible];
return YES;

} [/code]

However, for this to work now, window needs to be replaced with _window.

Just a snippet shown here:

//Place items view controller's tabel view in the window hierarchy [_window setRootViewController: itemsViewController];

Hope this helps and saves people a bit of time.


#2

thanks for the tip! Can you explain to why the _window was necessary? What is the difference between window and _window?


#3

Yeah, it helps. I finally see the table view rows.
why does it have to be _window in [_window setRootViewController:itemsViewController]; ?


#4

Huge kudos. I spent over 2 hours trying to get this to work - getting right to the end of the chapter and not seeing anything but a blank (unlined) screen. As a newbie iPhone programmer I didn’t have the ability to catch this minor error.

As soon as I inserted _ before window the table magically appeared.

This really is a significant issue - suggest it is pinned to the top of the board.

I’m surprised the authors did not post the response and it took bottlerocket to identify the 1 character fix.

THANK YOU!


#5

I tried that fix and that same thing happened, so I reviewed the downloadable code and noticed a slight difference in BNRItemStore

In the book, the header file states:

the downloaded header file has:

same in the method, the book states

[code]+ (BNRItemStore *)sharedStore
{
static BNRItemStore *sharedStore = nil;
if(!sharedStore)
sharedStore = [[super allocWithZone:nil] init];

return sharedStore;

}

  • (id)allocWithZone:(NSZone *)zone
    {
    return [self sharedStore];
    }[/code]

and the downloaded code has:

[code]+ (BNRItemStore *)defaultStore
{
static BNRItemStore *defaultStore = nil;
if(!defaultStore)
defaultStore = [[super allocWithZone:nil] init];

return defaultStore;

}

  • (id)allocWithZone:(NSZone *)zone
    {
    return [self defaultStore];
    }[/code]

So just…erm update those, and it works as expected, an no need to change the app delegate.
there went a couple of hours…