Q:

Swift Static table cell footer text

I have static cells in my UITableViewController, it contains 5 of static cell, I want to change only 3rd cell's footer text dynamically that comes from database, but I could not figured out how to do it. Not complex thing only change 3rd static cell's footer text, here is my sample codes
import UIKit
import CoreData

class settingsTableViewController: UITableViewController, UITextViewDelegate {

    // MARK: Outlets
    @IBOutlet weak var save: UIButton!
    @IBOutlet weak var message: UITextView!

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let cell = tableView.dequeueReusableHeaderFooterView(withIdentifier: "opsCell")

        // some of guides says you will change it with this function but I tried many times, it did not work.

        return cell
    }
}

Thanks people for your helps, it feels me bad.

A:

Please check below code :
override 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 = UIColor.lightGray

    switch(section) {
        case 2: // change only 3rd cell's footer
            let label = UILabel(frame: footerView.frame)
            label.text = "Section 5"
            footerView.addSubview(label)
            return footerView
        default: break
    }
    return nil
}

