Delegation in Swift

Boss those classes

Image for post
Image for post
Photo by Brooke Lark on Unsplash

Prerequisites:

Terminology

Why delegate?

The real life proxy

Image for post
Image for post
If a boss is poor at delegation, they take on too many tasks

The iOS application

Image for post
Image for post

UITableViewDelegate: Delegate Protocols

extension ViewController: UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print ("Selected: ", indexPath.row)
}
}

Delegate Protocols

Conclusion

Extend your knowledge

The Twitter contact:

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store