diff options
author | Nicholas Tay <nick@windblume.net> | 2022-03-21 15:13:23 +1100 |
---|---|---|
committer | Nicholas Tay <nick@windblume.net> | 2022-03-21 15:13:23 +1100 |
commit | 12abbe7e6ea257fa1686a2ef24fbf12009adcb8d (patch) | |
tree | fd26bb46fdd0915754cd36eafd42a0258cf60124 /foray/ForayTableViewController.swift | |
parent | ccd997e3c6c4262d58b21753fd69b31ca0a601e1 (diff) | |
download | forayios-12abbe7e6ea257fa1686a2ef24fbf12009adcb8d.tar.gz forayios-12abbe7e6ea257fa1686a2ef24fbf12009adcb8d.tar.bz2 forayios-12abbe7e6ea257fa1686a2ef24fbf12009adcb8d.zip |
First try at implementing coordinator pattern
Resources:
- https://www.hackingwithswift.com/articles/71/how-to-use-the-coordinator-pattern-in-ios-apps
Diffstat (limited to '')
-rw-r--r-- | foray/ForayTableViewController.swift | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/foray/ForayTableViewController.swift b/foray/ForayTableViewController.swift index 2732fce..827d4ea 100644 --- a/foray/ForayTableViewController.swift +++ b/foray/ForayTableViewController.swift @@ -13,7 +13,9 @@ private func firstDayOfYear(date: Date) -> Date { return calendar.date(from: components)! } -class ForayTableViewController: UITableViewController { +class ForayTableViewController: UITableViewController, ForayCoordinated { + + var coordinator: ForayCoordinator? // MARK: - Static data TEMP @@ -110,14 +112,10 @@ class ForayTableViewController: UITableViewController { return "Released in " + dateFormatter.string(from: section.year) } - let detailViewController: ForayDetailViewController = ForayDetailViewController() - override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) let item = self.sections[indexPath.section].items[indexPath.row] - detailViewController.setSelectedItem(selectedItem: item) - - self.navigationController?.pushViewController(detailViewController, animated: true) + self.coordinator?.showDetails(item: item) } } |