Implementing delegates in Swift
So, what are delegates? …in software development, there are general reusable solution architectures that help to solve commonly occurring problems within a given context, these “templates”, so to speak, are best known as design patterns. Delegates are a design pattern that allows one object to send messages to another object when a specific event happens. Imagine an object A calls an object B to perform an action. Once the action is complete, object A should know that B has completed the task and take necessary action, this can be achieved with the help of delegates! For a better explanation, I am going to show you how to create a custom delegate that passes data between classes, with Swift in a simple application, start by downloading or cloning this starter project and run it! You can see an app with two classes, ViewController A and ViewController B. B has two views that on tap changes the background color of the ViewController, ...