//Database 单例,第一种写法
class var instance: Database
{
struct Singleton
{
static let instance = Database()
}
return Singleton.instance
}
/*
//Database 单例,第二种写法
struct Static {
static var instance:Database? = nil
static var onceToken:dispatch_once_t = 0
}
class func sharedInstance() -> Database! {
/*
//普通闭包写法
dispatch_once(&Static.onceToken, { () -> Void in
Static.instance = Database()
})
*/
//尾随闭包写法
dispatch_once(&Static.onceToken) {
Static.instance = Database()
}
return Static.instance!
}
*/