Swift 单例

swift 的中已经抛弃dispatch_once函数,所以不能使用OC创建单例的模式在swift中创建单例了。
而swift创建单例的模式更加简单了,使用 Static关键字

1
2
3
4
5
class Singleton {
static let shareInstance = Singleton() //默认构造函数
}

Share Comments