Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) nearly matches optional requirement

I have a UIViewController like this:

class ViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        self.tableView.dataSource = self
        self.tableView.delegate = self
    }
}

extension ViewController: UITableViewDataSource {
     // datasource methods...
}       

extension ViewController: UITableViewDelegate {
    func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    }
}

But I get this warning:

Instance method 'tableView(:canEditRowAt:)' nearly matches optional requirement 'tableView(:canFocusRowAt:)' of protocol 'UITableViewDelegate'

And I can't remove that warning.

How can I remove that warning?

I have to commit the Xcode project for the company I work without any warnings and I can't find how to suppress the warning.

like image 907
pableiros Avatar asked Mar 10 '23 18:03

pableiros


1 Answers

The problem is that the tableView(_:canEditRowAt:) method is from the UITableViewDataSource protocol, not the UITableViewDelegate protocol. Move it to the other extension.

like image 179
rmaddy Avatar answered Apr 06 '23 09:04

rmaddy