0

I have the following error which I believe to be due to swift 3 new syntax vs an older tutorial I am following, any idea how to correct the error so I can use the function?

Cannot convert value of type '(UITableViewRowAction) -> ()' to expected argument type '(UITableViewRowAction, IndexPath) -> Void'

with this code

    func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {

    let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete")   { (rowAction: UITableViewRowAction, IndexPath: NSIndexPath) in
        print("delete me \(indexPath.row)")
    }
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
infernouk
  • 1,137
  • 4
  • 13
  • 21

1 Answers1

1

Your handler isn't correct. It needs to be:

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    let deleteAction = UITableViewRowAction(style: .destructive, title: "Delete")   { (_ rowAction: UITableViewRowAction, _ indexPath: IndexPath) in
        print("delete me \(indexPath.row)")
    }

    return [deleteAction]
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579