From a1e1e9d908daad6d0d21786f96f54f551cfa6fd7 Mon Sep 17 00:00:00 2001 From: Max Sokolov Date: Sat, 17 Mar 2018 00:03:53 +0300 Subject: [PATCH] add bounds check --- Sources/TableDirector.swift | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Sources/TableDirector.swift b/Sources/TableDirector.swift index a92f3db..b380865 100644 --- a/Sources/TableDirector.swift +++ b/Sources/TableDirector.swift @@ -102,12 +102,15 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate { cell: UITableViewCell?, indexPath: IndexPath, userInfo: [AnyHashable: Any]? = nil) -> Any? { - return sections[indexPath.section].rows[indexPath.row].invoke( - action: action, - cell: cell, - path: indexPath, - userInfo: userInfo - ) + if indexPath.section < sections.count && indexPath.row < sections[indexPath.section].rows.count { + return sections[indexPath.section].rows[indexPath.row].invoke( + action: action, + cell: cell, + path: indexPath, + userInfo: userInfo + ) + } + return nil } open override func responds(to selector: Selector) -> Bool {