Im trying to build my application using a custom UITableViewCell. This is the code in my UIViewController that adds the viewCell to the table:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"------- Tableview --------");
static NSString *myIdentifier = @"MyIdentifier";
MyTableCell *cell = (MyTableCell *)[tableView dequeueReusableCellWithIdentifier:myIdentifier];
if(cell == nil) {
NSArray *cellView = [[NSBundle mainBundle] loadNibNamed:@"tblCellView" owner:self options:nil];
cell = [cellView objectAtIndex:0];
}
[cell setLabelText:[NSString stringWithFormat:@"indexpath.row: %d", indexPath.row]];
//cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:myIdentifier] autorelease];
cell.textLabel.text = @"bös";
return cell;
}
if i uncomment the line above "return cell" it returns a regular UITableViewCell without any errors, but as soon as i try to implement my custom cell it crashes with this error:
------- Tableview -------- 2010-04-23 11:17:33.163 SogetGolf[26935:40b] * Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-984.38/UITableView.m:4709 2010-04-23 11:17:33.164 SogetGolf[26935:40b] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' 2010-04-23 11:17:33.165 SogetGolf[26935:40b] Stack: (
...
I have configured the .xib file as one should with the proper outlets. And the identifier of the UITableViewCell corresponds with name im trying to load from NSBundle