Skip to content

Instantly share code, notes, and snippets.

@amlcurran
Created June 12, 2016 12:58
Show Gist options
  • Save amlcurran/84321f88d71c322080fc893b806bf070 to your computer and use it in GitHub Desktop.
Save amlcurran/84321f88d71c322080fc893b806bf070 to your computer and use it in GitHub Desktop.
Delegation 2: extension
class FirstViewController: UIViewController {
private let items : [String] = [ /* some items */]
private let tableView = UITableView()
/* lots of other methods */
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
tableView.delegate = self
}
}
extension FirstViewController: UITableViewDelegate {
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let item = items[indexPath.row]
navigationController?.pushViewController(SecondController(item: item), animated: true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment