I have a tableview that contains 4 sections. In sections 2,3,and 4 I want to have a + button to add information to a "Saved" array. I have the logic setup for adding information, but I'm having issues with the tableview cells.
I don't want the + button to appear in section 0, since that's where we're adding the data. Here's my cellForRowAt method...
let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) as! SchoolTableViewCell
// Configure the cell...
if indexPath.section == 0 {
cell.textLabel?.text = "Test"
cell.addFavoritesButton.removeFromSuperview()
} else if indexPath.section == 1 {
cell.textLabel?.text = Items.sharedInstance.elementaryList[indexPath.row]
} else if indexPath.section == 2 {
cell.textLabel?.text = Items.sharedInstance.intermediateList[indexPath.row]
} else if indexPath.section == 3 {
cell.textLabel?.text = Items.sharedInstance.highschoolList[indexPath.row]
}
return cell
This works great at first! But if I scroll down, more and more cells will remove the button. It's not limiting it to section 0 because of reusable cells.
Can anyone think of a better way to remove this button for the first section only?

cell.addFavoritesButton.removeFromSuperview(). so when it's reused... * poof * bye bye forever sweet sweetaddFavoritesButton, don't care which section you're in - staticVoidMan