"invalid nib registered for identifier (myGoal) - nib must contain exactly one top level object which must be a UITableViewCell instance"
Thats the exception I keep on getting. I am using both, storyboard and XIB.
In my storyboard, I have a tableview inside of a navigation view. The tableview is set to dynamic prototypes and the number of prototype cells is zero. The reason is because I wanted to add a custom cell programmatically.
The first time I added the cells programmatically, I was using one of the generic cell styles. At it would work!
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"myGoal"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myGoal"
forIndexPath:indexPath];
//do stuff with cell
}
It would let me have a tableview with the default cell style, which has one label.
Next I wanted to customize my cell so that it would have multiple label and a few extra buttons. Normally, I'd do it in a storyboard interface builder, but this time I need to do it programatically.
So I created a custom tableviewcell class along with its Xib counterpart. In the Xib I designed it how I wanted. The problem is in getting this cell to show up in the tableview.
Does it matter that the tableview is in a storyboard and the tableviewcell is in a xib?
In order to register the custom nib, I did almost the same thing as above, yet it crashes:
- (void)viewDidLoad
{
[super viewDidLoad];
UINib *dhCustomNib = [UINib nibWithNibName:@"DHTableViewCell" bundle:nil];
[self.tableView registerNib:dhCustomNib forCellReuseIdentifier:@"myGoal"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
DHTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"myGoal"
forIndexPath:indexPath]; //It crashes at this point
//do stuff with cell
}
What am I missing?

UITableViewCell- Paul.sDHTableViewCellclass should be a subclass ofUITableViewCelland must be the only top level object in the nib - Paul.s