- Hands-On Design Patterns with Swift
- Florent Vilmart Giordano Scalzo Sergio De Simone
- 70字
- 2021-07-02 14:45:07
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.