pableiros pableiros - 1 month ago 17
Swift Question

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.

Answer

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