I've got some (I think) pretty basic code for creating cell content from a data source, and everything works fine when the display loads. However, when I start scrolling around to view other text (up or down) the code fails with 'GDB: Program received signal: "EXEC_BAD_ACCESS"'. Here's the code that fills out the display for the various sections; each section has similar code:
id cell = (UITableViewCell *)[tableView
dequeueReusableCellWithIdentifier:CellIdentifier
];
titledCell = [[[TitledCell alloc]
initWithFrame:CGRectZero
reuseIdentifier:CellIdentifier
] autorelease
];
switch (tableSection) {
case TABLE_SECTION_1:
if (cell == nil) {
dataKey = @"a key from data source";
dataFromSource = [viewData objectForKey:dataKey];
titledCell.title.text = dataKey;
titledCell.contents.text = dataFromSource;
cell = titledCell;
break;
}
case TABLE_SECTION_2:
...
}
return cell;
As I was following the code, I noticed that the code skips the cell creation when scrolling the cell back into view, because cell != nil. If it skips, that means that cell contains the same contents as the first time it was created, right? Why is giving me trouble?