I have created a .xib file which has more than 2 tableview cells. I used the following code in the viewDidLoad() method for registering nib to reuse cells.
UINib *nib = [UINib nibWithNibName:@"CartTableViewCells" bundle:nil];
[self.tableView registerNib:nib forCellReuseIdentifier:@"Cell0"];
[self.tableView registerNib:nib forCellReuseIdentifier:@"Cell1"];
[self.tableView registerNib:nib forCellReuseIdentifier:@"Cell2"];
And In - [UITableView CellForRowAtIndexPath] method, I used the following code.
cell0 = (CartTableViewCells *)[self.tableView dequeueReusableCellWithIdentifier:@"Cell0"];
if (cell0==nil)
{
cell0 = [[[NSBundle mainBundle] loadNibNamed:@"CartTableViewCells" owner:self options:nil] objectAtIndex:0];
}
But My app crashed with the following error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'invalid nib registered for identifier (Cell0) - nib must contain exactly one top level object which must be a UITableViewCell instance'