Implemented UITableView with custom UITableViewCell with below code
@interface ProfileSaveViewController : UITableViewController
{
UITableViewCell *cell0;
UITableViewCell *cell1;
UITableViewCell *cell2;
UILabel *cell2Label;
}
@property (nonatomic, retain) IBOutlet UITableViewCell *cell0;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell1;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell2;
@property (nonatomic, retain) IBOutlet UILabel *cell2Label;
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
{
if([indexPath row] == 0) return cell0;
if([indexPath row] == 1) return cell1;
if([indexPath row] == 2) return cell2;
return nil;
}
follwing message came when running the application.
* Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:6072 2012-03-01 11:11:31.984 TestSplitView[765:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
You're being asked for a cell and returning nil
(or maybe something else that's not a UITableViewCell
). It's just that simple.
I see two possibilities:
You are returning a number larger than 3 from tableView:numberOfRowsInSection:
. Don't.
One or more of your cell#
outlets is not hooked up in your nib, or is not hooked up to a UITableViewCell
(or subclass). Hook them up properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With