For many years, the primary languages that I used was C and C based object-oriented languages. These languages required a good handle on managing memory and knowing when to release memory. Luckily modern languages like Swift take care of managing the memory for us however it is a good idea to understand how this memory management works so we can avoid the pitfalls that cause this memory management to fail.
In this chapter we will learn:
- How ARC works
- What is a Strong Reference Cycle
- How to use Weak and unowned to prevent strong reference cycles
As we saw in Chapter15, Custom Types, structures are value types and classes are reference types. What this means is that when we pass an instance of a structure within our application, such as a parameter of a method, we create a new instance of the structure in the memory. This new instance of the structure is only...