是否有必要在UIView.animateWithDuration(...)的闭包中使用[unown self]? [英] Is it necessary to use [unowned self] in closures of UIView.animateWithDuration(...)?

查看:88
本文介绍了是否有必要在UIView.animateWithDuration(...)的闭包中使用[unown self]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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?

推荐答案

否,在这种情况下不需要. animationscompletion未被self保留,因此没有强大的保留周期的风险.

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.

这篇关于是否有必要在UIView.animateWithDuration(...)的闭包中使用[unown self]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆