No Empty Table View


#1

Hi

I have typed in and followed all the code on Page 172-175 of the book. The program builds and runs, however I don’t get a table view I get an empty window (not white).

I have re-checked the code but it all looks as it should be. here is the code. Any ideas?

ItemsViewController.h

[code]#import <Foundation/Foundation.h>

@interface ItemsViewController : UITableViewController {

}

@end
[/code]

ItemsViewController.m

[code]#import “ItemsViewController.h”

@implementation ItemsViewController

-(id)init
{
self = [super initWithStyle:UITableViewStyleGrouped];

return self;

}

-(id)initWithStyle:(UITableViewStyle)style
{
return [self init];
}

@end
[/code]

HomepwnerAppDelegate.h

[code]#import <UIKit/UIKit.h>

@interface HomepwnerAppDelegate : NSObject {

}

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

@end
[/code]

HomepwnerAppDelegate.m

[code]#import “HomepwnerAppDelegate.h”
#import “ItemsViewController.h”

@implementation HomepwnerAppDelegate

@synthesize window=_window;

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
    ItemsViewController *itemsViewController = [[ItemsViewController alloc]init];
    [[self window] setRootViewController:itemsViewController];

    [itemsViewController release];

    [[self window] makeKeyAndVisible];
    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication )application
    {
    /

    Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    */
    }

  • (void)applicationDidEnterBackground:(UIApplication )application
    {
    /

    Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    */
    }

  • (void)applicationWillEnterForeground:(UIApplication )application
    {
    /

    Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    */
    }

  • (void)applicationDidBecomeActive:(UIApplication )application
    {
    /

    Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    */
    }

  • (void)applicationWillTerminate:(UIApplication )application
    {
    /

    Called when the application is about to terminate.
    Save data if appropriate.
    See also applicationDidEnterBackground:.
    */
    }

  • (void)dealloc
    {
    [_window release];
    [super dealloc];
    }

@end
[/code]


#2

The screenshot is actually misleading, because it shows a plain table view, when in the chapter we’re using a grouped table view. If your background is non-white, you’re ok, just keep going.


#3

Great, thank you. I also struggled for a long time trying to fix it. Please update the errata for this Chapter, because I’m sure I’m not the only one!


#4

Thank you, this threw me for a loop, too.


#5

I didn’t get those rows either for the first part of the chapter project. I tried a second time and compared line by line. thanks for sharing so i can move on.
Also by using Xcode 4.2 now, there is no windows based application any more, which kind application would be the most close one? empty application ?


#6

to answer my own post. I now get empty table view and also possession description.
two things:

  1. you need _window instead of window in [_window setRootViewController:itemsViewController] to get the empty table view
  2. you need to set return 1 instead of 0 in section shown below:
  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    // Return the number of sections.
    return 1;
    }
    thanks,