0

I've certain methods which are repeated in many table views. Is it possible to move this implementation in separate common class? If yes then how? Code please. Is there any way to avoid this repetition?

One example of such implementation is giving space in the footer below last cell which I end up in repeating.

extension MessagesViewController: UITableViewDelegate {

    // Set space below footer
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let footerView = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 40))
        footerView.backgroundColor = .clear
        return footerView
    }

    // Set height for footer
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 40
    }
}
Raymond
  • 1,108
  • 13
  • 32

1 Answers1

0

I implemented common delegates in a parent class and inherited VC from this class. It worked.

Raymond
  • 1,108
  • 13
  • 32