In a nutshell, using closures for delegates puts the responsibility of ownership management on the delegatee rather than the delegator. But by packaging the delegate into a setter, Oleg shows us we can control how it’s captured with respect to the closure (and, as a bonus, reduce our free-floating closures with more trailing closure syntax).
Something that tends to be particularly tricky when it comes to finding a good balance between convenience & maintainability, is when setting up relationships between the view layer and the model layer. This week, let's take a look at a few different ways that we can decouple our UI code from our model code, and some of the benefits of doing so.
Everyone has worked with UserDefaults in order to store some simple data and knows that working with that storage is easy as it can be. But we can improve the interaction with it a bit though! Let’s start with the most obvious solution and implement something new and elegant.