retain cycle between MacawView and MacawZoom: both classes referenced to each other using strong reference which produced retain cycle previously.
Solution is easy - just to use some weak / unowned reference.
implicit retain cycle with onZoomChange method. As we know - self is also implicitly captured when we pass method as closure.
So instead of directly passing method name as closure - zoom.initialize(view: self, onChange: onZoomChange) we have to wrap it into additional closure with [weak self] parameter in capture list:
zoom.initialize(onChange: { [weak self] transform in
self?.onZoomChange(t: transform)
})
Updates
In this pull request I fixed 2 issues:
retain cycle between
MacawView and MacawZoom
: both classes referenced to each other using strong reference which produced retain cycle previously. Solution is easy - just to use some weak / unowned reference.implicit retain cycle with
onZoomChange
method. As we know -self
is also implicitly captured when we passmethod
asclosure
. So instead of directly passing method name as closure -zoom.initialize(view: self, onChange: onZoomChange)
we have to wrap it into additional closure with [weak self] parameter in capture list: