Created
September 11, 2017 12:02
-
-
Save Quaggie/e87670fbba9a00625c74009e1f57c19b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DataSource: NSObject { | |
| typealias Callback = ((IndexPath) -> Void)? | |
| var names = [String]() | |
| fileprivate var callback: Callback | |
| init(names: [String]) { | |
| super.init() | |
| self.names = names | |
| } | |
| } | |
| extension DataSource: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return names.count | |
| } | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| return UITableViewCell() | |
| } | |
| } | |
| extension DataSource: UITableViewDelegate { | |
| func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | |
| callback?(indexPath) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment