Xcode构建失败

时间:2017-01-19 23:44:19

标签: swift xcode uitableview

我一直收到错误:

  

无法转换类型的值'(UITableViewRowAction!,NSIndexPath!) - >   Void'到期望的参数类型'(UITableViewRowAction,IndexPath) - >   无效“

有谁知道我能做些什么来摆脱这个错误?

func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
    var shareAction = UITableViewRowAction(style: .normal, title: "Share") { 
        (action:UITableViewRowAction!, indexPath: NSIndexPath!) -> Void in
            let firstActivityItem = self.animals[indexPath.row]
            let activityViewController = UIActivityViewController(activityItems: [firstActivityItem], applicationActivities: nil)
            self.presentviewcontroller(activityViewController, animated: true, completion: nil)
    }
    shareAction.backgroundColor = UIColor.blueColor()
    return [shareAction]
}

1 个答案:

答案 0 :(得分:0)

替换

(action:UITableViewRowAction!, indexPath: NSIndexPath!)

(action:UITableViewRowAction, indexPath: IndexPath)

或者,甚至更好,只是

(action, indexPath)