Swift 单例
2016-06-08 本文已影响58人
Mr_滑
class var shareInstance:BaseMainViewController {
struct Static {
static var onceToken : dispatch_once_t = 0
static var instance : BaseMainViewController? = nil
}
dispatch_once(&Static.onceToken){
Static.instance = BaseMainViewController()
}
return Static.instance!
}
内容转载
swift实现单例的四种方式 http://www.jianshu.com/p/230cc900948c
Swift中编写单例的正确方式 http://my.oschina.net/jeans/blog/541750