views:

39

answers:

3

I checked using the debbuger in the viewDidLoad method and tracerTableView is 0x0 which i assume means it is nil. I don't understand. I should go ahaed say yes I have already checked my nib file and yes all the connections are correct. Here is the header file and the begging of the .m.

/////////////
.h file
////////////

@interface TrackerListController : UITableViewController {

// The mutable (modifiable) dictionary days holds all the data for the days tab
NSMutableArray *trackerList;
UITableView *tracerTableView;
}

@property (nonatomic, retain) NSMutableArray *trackerList;
@property (nonatomic, retain) IBOutlet UITableView. *tracerTableView;

//The addPackage: method is invoked when the user taps the addbutton created at runtime.

-(void) addPackage : (id) sender;

@end

///////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////
.m file
//////////////////////////////////////

@implementation TrackerListController

@synthesize trackerList, tracerTableView;

  • (void)viewDidLoad {

    [super viewDidLoad];

    self.title = @"Package Tracker";

    self.navigationItem.leftBarButtonItem = self.editButtonItem;

UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self >action:@selector(addPackage:)];

// Set up the Add custom button on the right of the navigation bar self.navigationItem.rightBarButtonItem = addButton;

[addButton release]; // Release the addButton from memory since it is no longer needed

}

A: 

Perhaps you have a typo. The following line:

@property (nonatomic, retain) IBOutlet UITableView. *tracerTableView;

should be:

@property (nonatomic, retain) IBOutlet UITableView *tracerTableView;

To be clear, in the header file, I would declare the table view to be an Interface Builder outlet:

IBOutlet UITableView *tracerTableView;

After doing this, to double-check, I would also make sure the File's Owner (the view controller) in your XIB is wired up from the File's Owner to the Table View.

Alex Reynolds
+1  A: 

The table is already an IBOutlet. You can specify those on 2 places, first in the declaration or on the @property line. So that seems ok.

The tableview is connected to the tracerTableView property in the .h file and you synthesize them correctly.

How do you load the ViewController. Do you init it with NibName? Could you maybe post that code too? Because just initializing it as:

TrackerListController* viewControl = [[TrackerListController alloc] init];

Doesnt seem to work when you want to use a nib. Try using this instead:

TrackerListController* viewControl = [[TrackerListController alloc]
initWithNibName:@"trackerListController" bundle:nil];
Wim Haanstra
A: 

Wim thanks you so much, that was the problem EXACTLY. I forgot to init with a nib. Amazing call...

Thanks again that was perfect

Jamie L
Glad it worked! I have been experiencing the same thing some time ago.You should tag the reply as answer, so people will know this will fix their problem when they are encountering the same thing.
Wim Haanstra