1

I am using Xcode 9.2. I am adding an expandable effect for my table view. I set the delegate in viewDidLoad and make an extension of the view controller for the expandable delegate protocol.

My problem is Xcode shows an "Do you want to add protocol stubs?" error message again and again which I have already added 2 times by clicking the Fix it button.

Can anyone suggest me what am I missing?

class MenuController: UIViewController,MFMailComposeViewControllerDelegate {

    var coverView = UIView()

    @IBOutlet weak var tblViewMenu: ExpandableTableView!

override func viewDidLoad() {
        super.viewDidLoad()
        revealViewController().revealToggle(animated: false)

 tblViewMenu.expandableDelegate = self as! ExpandableTableViewDelegate
        tblViewMenu.register(UINib(nibName: "ExpandCell1", bundle: nil), forCellReuseIdentifier: "ExpandCell1")
    }
}

Extension

extension MenuController: ExpandableDelegate {

    func expandableTableView(_ expandableTableView: ExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell:ExpandCell1 = tblViewMenu.dequeueReusableCell(withIdentifier: "ExpandCell1") as! ExpandCell1
        cell.textLabel?.text = "TableViewCellMain"           
        return cell
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, numberOfRowsInSection section: Int) -> Int {
        return 5
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 44
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCellsForRowAt indexPath: IndexPath) -> [UITableViewCell]? {
        let cell:CellTableView1 = tblViewMenu.dequeueReusableCell(withIdentifier: "CellTableView1") as! CellTableView1
        cell.textLabel?.text = "CellTableView1"
        return [cell]
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, heightsForExpandedRowAt indexPath: IndexPath) -> [CGFloat]? {
         return [200]
    }

    func numberOfSections(in tableView: ExpandableTableView) -> Int {
        return 1
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectRowAt indexPath: IndexPath) {
        //        print("didSelectRow:\(indexPath)")
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, didSelectExpandedRowAt indexPath: IndexPath) {
        //        print("didSelectExpandedRowAt:\(indexPath)")
    }

    func expandableTableView(_ expandableTableView: ExpandableTableView, expandedCell: UITableViewCell, didSelectExpandedRowAt indexPath: IndexPath) {

    }

    func expandableTableView(_ expandableTableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
        return true
    }

    func expandableTableView(_ expandableTableView: UITableView, didUnhighlightRowAt indexPath: IndexPath) {

    }
}

Screenshot

screenshot of the error

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
Chandni
  • 692
  • 1
  • 10
  • 25

1 Answers1

0

This is an Xcode bug. The project will build correctly and run, but the error stays there. If you want to get rid of the error, clean the project. If that doesn't help, quit Xcode and delete the DerivedData folder.

Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223