Swift 闭包中 self? 的由来
class UIViewSpringAnimator: SwipeAnimator {
// 动画完成的闭包
var completion:((Bool) ->Void)?
func addCompletion(completion:@escaping (Bool) ->Void) {
self.completion = { [weakself] finished in
guardself?.isRunning ==true else {return }
self?.isRunning =false
self?.animations =nil
self?.completion =nil
completion(finished)
}
}
}
[weak self] 的作用
我思故我在