Fixing the leak

Now that we've seen a simple leak, we have to change our implementation, in order to prevent the leaks from occurring. In our case, this can lead to other unexpected behavior. We have multiple options to resolve this particular self reference, as follows:

  • Using weak
  • Using unowned
  • Ensuring that we never set ref = self

Let's investigate the solutions that involve weak and unowned.