From 60003d75573dc2f65886b40f8b95681202c7ae0b Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Mon, 22 Aug 2016 17:36:08 +0300 Subject: [PATCH] support editing actions in TableDirector --- Sources/TableDirector.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index bfdb60e..81b8b5d 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -203,6 +203,23 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate return indexPath } + // MARK: - Row editing - + + public func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool { + return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath) + } + + public func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { + return sections[indexPath.section].rows[indexPath.row].editingActions + } + + public func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { + + if editingStyle == .Delete { + invoke(action: .clickDelete, cell: tableView.cellForRowAtIndexPath(indexPath), indexPath: indexPath) + } + } + // MARK: - Sections manipulation - public func append(section section: TableSection) -> Self {