How can I protect Text of UITableViewCell, which gets changed on scrolling of the UITableView.
static NSString *CellIdentifier = @"Cell";
CustomTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(indexPath.row != [destinationList count])
{
if (cell == nil)
{
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.customLable.text = @"MyCustomLabel";
else
{
if (cell == nil)
{
cell = [[CustomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"Static Text to be set";
[cell.customLable removeFromSuperview];
}
Problem: Every time I scroll the UITableView, @”Static Text to be set” gets overwritten on @”MyCustomLabel”.
How can I prevent this? I want all the cells of UITableView to retains their TextLabels through Table’s LifeTime.
Two possible answers: