Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save olivaresf/cd41cd633aeb75e9f5c1aa2cecb2109d to your computer and use it in GitHub Desktop.
Save olivaresf/cd41cd633aeb75e9f5c1aa2cecb2109d to your computer and use it in GitHub Desktop.
Delegation in VCs
protocol CurrencyPickerProtocol : class {
func selected(currency: String, from: CurrencyPickerTableViewController)
}
class CurrencyPickerTableViewController: UITableViewController {
weak var delegate: CurrencyPickerProtocol
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let key = order[indexPath.row]
delegate.selected(currency: key, from: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment