UITableViewController crashes with a exc bad accesses error. This is my code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NSString *cellText ;
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
}
if (indexPath.row == 0)
{
cellText = @"Mail1";
}
else if (indexPath.row == 1)
{
cellText = @"Mail2";
}
else if (indexPath.row == 2)
{
cellText = @"Mail3";
}
else if(indexPath.row == 3)
{
cellText = @"Mail4";
}
else
{
cellText = @"Mail5";
}
cell.textLabel.text = cellText;
return cell;
}
this is the log message xcode gave
XXXXProject[1366:f803] * -[XXXXViewController tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x6a793f0