Create a push behavior with a certain magnitude and angle. And look what I've got. Set the push behavior's action to be, remove this push behavior from the dynamic animator. Since its instantaneous, see how its mode is instantaneous? This is fine. I want this thing removed. I don't want it setting around there collecting dust because it's not going to fire ever again. It fired, the action method got called, I put this closure method in here to do this.
But of course this has a memory cycle, a really bad one. Because this push behavior has a var action which is a closure. So it has a strong pointer to this closure. Push behavior's action is a strong pointer to this closure. And this closure references the push behavior, so it has a strong pointer back to the push behavior. So this will happen just fine and now the only people pointing to this push behavior, since it got removed from the dynamic animator, the only thing pointing to it is this closure. And it's pointing to closure, so they're keeping each other in the heep. So this is our classic memory cycle.
And just to remind how we break it here. We are just going to put unowned push behavior in here. Cuz we know that this can never be out of the heep when action is called by definition.
Action is only called when his push behavior does anything. So it has to clearly still be in the heep done anything .