Is it necessary to use [unowned self] in closures of UIView.animateWithDuration(...)?

WildCat picture WildCat · Nov 19, 2014 · Viewed 11.2k times · Source
    UIView.animateWithDuration(1,
        animations: { [unowned self] in
            self.box.center = self.boxTopRightPosition
        },
        completion: { [unowned self] completed in
            self.box.hidden = true
    })

Is it necessary to avoid memory leak?

Answer

Kirsteins picture Kirsteins · Nov 19, 2014

No, it is not needed in this case. animations and completion are not retained by self so there is no risk of strong retain cycle.