博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Swift 闭包中 self? 的由来
阅读量:2092 次
发布时间:2019-04-29

本文共 340 字,大约阅读时间需要 1 分钟。

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] 的作用
你可能感兴趣的文章