Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 715 Bytes

22.单例.md

File metadata and controls

31 lines (22 loc) · 715 Bytes

22.单例

class Singleton {
    // “懒实例化”的全局变量会被自动放在dispatch_once块中
    static let singleton =  Singleton() 
    private init(){}
}

class SingletonManager: NSObject {
     static let singleton = SingletonManager()
     private override init() {
     }
}