I experienced something odd with UIView animation blocks.
A view never deallocated after I run my animation code. Before calling animation code I set the view property to nil. Then inside the completion block I removed it from superview so after fade out it's gone.
But -dealloc of that faded out and removed view is never called. Then I thought maybe the completion block retains the view and made a weak reference using __weak
which worked. Suddenly the view deallocated properly after animation completion.
But in the animation block itself I simply reference the view and set its alpha to 0. No __weak
reference and still the view deallocates properly.
Conclusion: iOS cleans up the animation block after animation is done. But it does NOT clean up the completion block. Means: You must use __weak references for everything in the completion block because it sticks around forever.
Is there a magic way to trigger completion block disposal or cleanup so it releases all strong references? Of course I use ARC btw.