swift3-17 单例

单例写法

public class Manager{
    public var score = 0
    public static let defaultManager = Manager.init()

    private init(){

    }
    public func addScore(){
        score += 10
    }
}




let manager = Manager.defaultManager

manager.addScore()
manager.score

manager.addScore()
manager.score
let manager2 = Manager.defaultManager
manager2.addScore()
manager2.score