You have a strong reference to self in the action closure. Add ”[weak self] in”

12
vingrishOP•

I've run the code with [weak self]. It doesn't help. In my limited understanding, the cycle should be broken when self.anim.removeAllBehaviors();self.mv!.removeFromSuperview() is executed.

##Update

With the "Debug Memory Graph" tool in XCode, I saw UIGravityBehavior is still retained by the animator even after self.anim.removeAllBehaviors() is called.

0
[deleted]•

[removed]

1
Spaceshipable•

Just as a house keeping thing, try and avoid abbreviations for variable names

0
phughes•

As a rule I keep my variable name lengths directly proportional to how far away from their declaration they are used.

If you're creating a view controller and immediately pushing it on the nav stack it's OK to call it vc.
If it's private to a small class a single word can be appropriate.
If it's a property that is going to be accessed from outside the class it'd better be named clearly.

3
lucasvandongen•

Dear predecessor,

I would prefer you to be at least consistent when you screw up your variable names.

Sincerely,

​

The axe murderer that is going to maintain your code

5
europeanwizard•

Exactly this. I don't see anything wrong with using short variable names when they're really narrowly scoped and used right away.

I don't do it, because of the current code standards at this client. But my preference is to keep such names brief.

2
Spaceshipable•

Maybe its just me, but i'd always rather see a fully expanded variable name. I think its just much much easier to read. I don't know what the advantage of shortened names is

2
vingrishOP•

Thanks. In practice I use abbreviations only for locals. I use abbreviations here because the code snippet is not very long:-)

0
vingrishOP•

Many of us may be considering using a [weak self] here. But that won't help.

0