pableiros
pableiros

Reputation: 16052

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.

Upvotes: 4

Views: 1178

Answers (1)

rmaddy
rmaddy

Reputation: 318854

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

Upvotes: 7

Related Questions